SAS: A Complete Guide to CAT, CATT, CATS

Yes, this is a comprehensive guide to the four major SAS Programming Procedures: CAT, CATT, CATS and CATX. It provides step-by-step instructions on how to use each procedure, along with examples to help you understand the concepts more clearly. Additionally, it offers tips and guidelines to help you make the best decisions when using the procedures.


You can use the CAT, CATT, CATS & CATX functions to concatenate string variables together in SAS.

Here is the difference between the various functions:

The CAT function concatenates string variables without removing any blanks.

The CATT function removes trailing spaces from strings and then concatenates string variables.

The CATS function removes both leading and trailing spaces from strings and then concatenates string variables.

The CATX function removes both leading and trailing spaces from strings and then concatenates string variables with a custom delimiter.

The following example shows how to use each function in practice.

Example: How to Use CAT, CATT, CATS & CATX in SAS

Suppose we have the following dataset in SAS that contains three string variables:

/*create dataset*/
data my_data;
input player $ team $ conf $;
datalines;
Andy Mavs West
Bob Lakers West
Chad Nuggets West
Doug Celtics East  
Eddy Nets East  
;
run;

/*view dataset*/
proc print data=my_data;

Now suppose that we would like to use the CAT, CATT, CATS & CATX functions to concatenate these three string variables into a single variable.

We can use the following code to do so:

/*create new dataset that concatenates columns*/
data new_data;
set my_data;
cat = cat(player, team, conf);
catt = catt(player, team, conf);
cats = cats(player, team, conf);
catx = catx('-', player, team, conf);
run;

/*view dataset*/
proc print data=new_data;

SAS CAT CATT CATS and CATX functions

Notice that the various concatenate functions have all concatenated the three string variables in slightly different ways.

The CAT function concatenated the three strings and left the spaces in between them.

The CATS function removed both leading and trailing spaces from each string and then concatenated them.

The CATX function removed both leading and trailing spaces from each string and then concatenated them using a dash ( ) as a delimiter.

When working with these concatenation functions on your own data, feel free to use whichever one is most suitable for your situation.

The following tutorials explain how to perform other common tasks in SAS:

x