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".)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.