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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 781 views
  • 5 likes
  • 5 in conversation