BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
girl_withno_nam
Calcite | Level 5

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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".)

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

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".)

girl_withno_nam
Calcite | Level 5
Thank you! I've tried the first solution and that works... will take a look at upgrading to your second solution too!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1282 views
  • 3 likes
  • 2 in conversation