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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 913 views
  • 5 likes
  • 5 in conversation