I have the following macro variable(s)
%LET LIVE_DATE = 07JUL2021;
DATA _NULL_;
CALL SYMPUT('DAY_NUM',WEEKDAY("&LIVE_DATE"D));
RUN;
%PUT &DAY_NUM;
So DAY_NUM returns the value 4 and I want to use DAY_NUM in place of the hardcoded 4 later within the code:
WEEK_START = INTNX('WEEK1.4',DTE_RCVD,0);
But I can't figure out how to do this ... &, &&, how many quotation marks, where ??
Is it even possible?
Any help appreciated, thank you!
Hello @girl_withno_nam and welcome to the SAS Support Communities!
First, use CALL SYMPUTX instead of CALL SYMPUT to avoid leading blanks in macro variable DAY_NUM and an unwanted note (about numeric-to-character conversion) in the log.
Then replace the single quotes in the first argument of the INTNX function with double quotes and the hardcoded 4 with the macro variable reference as usual:
"WEEK1.&DAY_NUM"
Edit: Alternatively, if &DAY_NUM is used only in that INTNX function call, you can plug in the definition directly, without the preceding DATA step:
"WEEK.%sysfunc(weekday("&live_date"d))"
(Omitted the redundant "1" after "WEEK".)
Hello @girl_withno_nam and welcome to the SAS Support Communities!
First, use CALL SYMPUTX instead of CALL SYMPUT to avoid leading blanks in macro variable DAY_NUM and an unwanted note (about numeric-to-character conversion) in the log.
Then replace the single quotes in the first argument of the INTNX function with double quotes and the hardcoded 4 with the macro variable reference as usual:
"WEEK1.&DAY_NUM"
Edit: Alternatively, if &DAY_NUM is used only in that INTNX function call, you can plug in the definition directly, without the preceding DATA step:
"WEEK.%sysfunc(weekday("&live_date"d))"
(Omitted the redundant "1" after "WEEK".)
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.