BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

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.

5 REPLIES 5
ballardw
Super User

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 ..

robertrao
Quartz | Level 8

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????????

ballardw
Super User

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.

robertrao
Quartz | Level 8

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

So what happens there? with CATT

Thanks

ballardw
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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