BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
japelin
Rhodochrosite | Level 12

I strongly recommend debugging to create a data step that works properly before create a macro code.

 

 

%macro testmacro;
data test1;
%let start_dt = '01jun2020'd;
%let add = (9 8 7 6 5 11 10);

do i=0 to 12;
varname = catt('month',put(i,z2. -l));   /* what does "-l" means? */
varvalue=intnx('month',"start_dt"d,+1*i,'b');/* change "start_dt"d to &start_dt */
format var_value date9.;                      /* var_value or varvalue? typo? */
call symputx(varname,put(varvalue,date9.) 'g');   /* "," needs before 'g' */

%let trialdate = %sysfunc(intnx(month,&start_dt,+1*i,b));/* why not using call symput(x) but using %let in data step  */
%let trialdate2 = %eval(&trialdate+%scan(&add,%sysfunc(weekday(&trialdate))));/* if you want to use %let change from do loop with i to %do loop with &i  */

output;
end;
run;
mend;
%testmacro;

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
  • 15 replies
  • 2343 views
  • 5 likes
  • 5 in conversation