Macro variable not concatenating ? Using SAS 9.4 TS Level 1M1

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Macro variable not concatenating ? Using SAS 9.4 TS Level 1M1

I have tried both the || (bar bar) and the CATS function, but I cannot get the Macro Variable to concatenate. Works with a 'standard' variable.
Any suggestions or is this a SAS feature Smiley Wink
See below the Macro Variable FNAME

OPTIONS SYMBOLGEN MPRINT;
**********************************************;
%LET FALLQTR = 2078;
%LET FALLDESC = FALL2007;
%LET FNAME = 'ENRL' || &FALLQTR || '_FALL' || &FALLQTR;
**********************************************************************;
DATA SASMASH;
ENFILE  = CATS('ENRL',&FALLQTR,'_FALL',&FALLQTR);
%PUT &FNAME;
put enfile;
RUN;

********** LOG
SYMBOLGEN:  Macro variable FNAME resolves to 'ENRL' || 2078 || '_FALL' || 2078  <----- does not concatenate ???
'ENRL' || 2078 || '_FALL' || 2078
358  put enfile;
359  RUN;

ENRL2078_FALL2078    <--- value of variable enfile does concatenate !!!!


Accepted Solutions
Solution
‎07-08-2015 03:29 PM
Respected Advisor
Posts: 3,124

Re: Macro variable not concatenating ? Using SAS 9.4 TS Level 1M1

%LET FNAME = ENRL&FALLQTR._FALL&FALLQTR;

|| is used in conventional SAS code, not Macro language. For Macro variable, you just put them out there. And be careful on the quoting when use with cats() function. You get lucky the value of your macro variable is number, try other chars other than number.

View solution in original post


All Replies
Solution
‎07-08-2015 03:29 PM
Respected Advisor
Posts: 3,124

Re: Macro variable not concatenating ? Using SAS 9.4 TS Level 1M1

%LET FNAME = ENRL&FALLQTR._FALL&FALLQTR;

|| is used in conventional SAS code, not Macro language. For Macro variable, you just put them out there. And be careful on the quoting when use with cats() function. You get lucky the value of your macro variable is number, try other chars other than number.

Occasional Contributor
Posts: 9

Re: Macro variable not concatenating ? Using SAS 9.4 TS Level 1M1

Thanks it works. I also noticed the period(.) to terminate the FALLQTR macro prior to the TEXT value '_FALL'

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 201 views
  • 0 likes
  • 2 in conversation