Help using Base SAS procedures

What does "CAT" means?

Reply
Regular Contributor
Posts: 161

What does "CAT" means?

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;
SAS Super FREQ
Posts: 8,743

Re: What does "CAT" means?

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
Super User
Posts: 9,681

Re: What does "CAT" means?

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


Ksharp
Respected Advisor
Posts: 3,777

Re: What does "CAT" means?

> 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.
Super User
Posts: 9,681

Re: What does "CAT" means?

Hi. data _null_;


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

Best Regards
Ksharp.
Ask a Question
Discussion stats
  • 4 replies
  • 447 views
  • 0 likes
  • 4 in conversation