## CATT function

Super Contributor
Posts: 1,041

# CATT function

Can someone ecplain How the CATT is working???

i dint understand what is given in the Documentation

The following example shows how the CATT function concatenates strings.
data _null_;
x='  The   Olym';
y='pic Arts Festi';
z='  val includes works by D  ';
a='ale Chihuly.';
result=catt(x,y,z,a);
put result \$char.;
run;

The following line is written to the SAS log:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7
The   Olympic Arts Festi  val includes works by Dale Chihuly.

Super User
Posts: 13,550

## Re: CATT function

Posted in reply to robertrao

CATT only removes TRAILING blanks. So the double spaces in X are not affected by the concatenation. Likewise the space at the start (a leading blank) of Z remains leaving the "Festi val" in the result. But the space after D in Z is removed so the result is Dale ..

Super Contributor
Posts: 1,041

## Re: CATT function

I get your point.

if in this example if  i=1

x=catt(x,' t_',left(i),' d_',left(i));

I am getting space t_1SPACEd_1 since a leading space is introduced fot t_ and d_????

if that leading space was not introduced i would have got t_1d_1t_2d_2 etc etc

Is my understanding of this right????????

Super User
Posts: 13,550

## Re: CATT function

Posted in reply to robertrao

It looks like you have it. If you don't want either leading or trailing spaces then use CATS, if you don't want leading or trailing spaces from the components of the concatenation but want to add a delimiter between the pieces then use CATX.

Super Contributor
Posts: 1,041

## Re: CATT function

Also in the first iteration the value of X is a SPACE.

So what happens there? with CATT

Thanks

Super User
Posts: 13,550

## Re: CATT function

Posted in reply to robertrao

If the only character is a space, it is both a leading and trailing space. Since it is a leading space, CATT removes it.

Discussion stats
• 5 replies
• 339 views
• 3 likes
• 2 in conversation