Difference between CAT, CATT, CATS, CATX function in SAS

In this section we will explain the difference between CAT, CATT, CATS, CATX Function in SAS. CATT Function in SAS concatenates and Removes the Trailing blanks.  CAT Function in SAS concatenates and does not remove leading or trailing blanks in SAS. CATS Function in SAS concatenates and removes leading and trailing blanks. CATX Function in SAS concatenates and removes leading and trailing blanks with delimiter inserted.

  • CATT Function in SAS removes trailing blanks
  • CAT Function in SAS does not remove leading or trailing blanks.
  • CATS Function in SAS Removes leading and trailing blanks.
  • CATX Function in SAS- CATX(deliminter,list) Removes leading and trailing blanks, and inserts deliminter;

So we will be using EMP_DET Table in our example

Difference between CAT, CATT,CATS,CATX functions in SAS 1

 

 

CAT Function in SAS – Concatenate and does not remove leading & Trailing Space:

CAT Function in SAS takes two columns as arguments and concatenates and does not remove leading and trailing spaces


/* CAT - Dose not remove leading or trailing blanks.*/ 

data EMP_DET1; 
set EMP_DET; 
state = CAT (state_name,state_code); 
run;

So the resultant table will be

Difference between CAT, CATT,CATS,CATX functions in SAS 2

 

 

CATT Function in SAS – Concatenate and removes Trailing Space:

CATT Function in SAS takes two columns as arguments and concatenates and removes trailing spaces

/* CATT - Removes trailing blanks */ 

data EMP_DET1; 
set EMP_DET; 
state = CATT(state_name,state_code); 
run;

So the resultant table with leading and trailing space removed will beDifference between CAT, CATT,CATS,CATX functions in SAS 3

 

CATS Function in SAS – Concatenate and removes both leading & Trailing Space:

CATS Function in SAS takes two columns as arguments and concatenates by removing leading and trailing space

/* CATS - Removes leading and trailing blanks */ 

data EMP_DET1; 
set EMP_DET; 
state = CATS(state_name,state_code); 
run;

So the resultant table with leading and trailing space removed will be
Difference between CAT, CATT,CATS,CATX functions in SAS 4

 

CATX Function in SAS – Concatenate and removes both leading & Trailing Space with delimiter:

CATX Function in SAS takes two columns as arguments and concatenates by removing leading and trailing space along with ‘-’ delimiter as shown below


/* CATX - Removes leading and trailing blanks and inserts a delimiter */ 
 
data EMP_DET1; 
set EMP_DET; 
state = CATX('-', state_name,state_code); 
run;

So the resultant table with leading and trailing space removed with delimiter ‘-’ will be

Difference between CAT, CATT,CATS,CATX functions in SAS 5

 

                                                                                                   

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts