BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Hello,

I was wondering if someone could explain to me what "CAT" means in this code?
Also what did the author tried to do?
Thank you in advance


code:
DATA kernel; LENGTH scorepattern $10 attpattern $&numatt.; SET kernel;
scorepattern = CAT(OF item scoreatt1-scoreatt&numatt.);
attpattern = CAT(OF scoreatt1-scoreatt&numatt.);
RUN;
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
The CAT function concatenates text strings or text variable values without removing leading or trailing blanks.
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002257060.htm

For more information on the use of the &MACVAR reference (in your code, &NUMATT), this paper provides a good introduction:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

Without knowing how &NUMATT is being created (%LET or CALL SYMPUT) or what the whole rest of the program is doing, it looks like &NUMATT is going to supply a value for the LENGTH and the other statements. For example, if &NUMATT is 4, then the compiler would receive this "resolved" code:
[pre]

DATA kernel;
LENGTH scorepattern $10 attpattern $4;
SET kernel;
scorepattern = CAT(OF item scoreatt1-scoreatt4);
attpattern = CAT(OF scoreatt1-scoreatt4);
RUN;
[/pre]

and if the macro variable &NUMATT had been assigned a value of 6, then this would be the "resolved" code that was sent to the compiler:
[pre]
DATA kernel;
LENGTH scorepattern $10 attpattern $6;
SET kernel;
scorepattern = CAT(OF item scoreatt1-scoreatt6);
attpattern = CAT(OF scoreatt1-scoreatt6);
RUN;
[/pre]

You are dealing with the WORK.KERNEL data -- how does it get created?? If you do a PROC CONTENTS on WORK.KERNEL, how do the SCOREATT1-SCOREATTn variables get created??? How many numbered variables are there? Can the number of "SCOREATT" variables change and if so, based on what condition??

cynthia
Ksharp
Super User
Hi.
cat() function is identical with ' || ' ,except that length of concatenated result is 200, and ' || ' has not this limit.


Ksharp
data_null__
Jade | Level 19
> cat() function is identical with ' || ' ,except that
> length of concatenated result is 200, and ' || ' has
> not this limit.

RTM

In a DATA step, if the CAT function returns a value to a variable that has not previously been assigned a length, then that variable is given a length of 200 bytes. If the concatenation operator (||) returns a value to a variable that has not previously been assigned a length, then that variable is given a length that is the sum of the lengths of the values which are being concatenated.
Ksharp
Super User
Hi. data _null_;


That is what I mean.But I forgetted to mention the 'length ' statement.
Thanks for adding it.

Best Regards
Ksharp.

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
  • 4 replies
  • 2286 views
  • 0 likes
  • 4 in conversation