Hi,
I have a macro "microsim" with 2 parameters, which are a starting year and an ending year. I want to loop this macro by increasing the year by 5 from 2010 until 2060.
In other words, the loop should do:
%microsim(2010,2015);
%microsim(2015,2020);
%microsim(2020,2025);
...
%microsim(2055,2060);
I was thinking to do something like:
%macro loop(start,end);
%local year;
%do year = &start %to &end;
%microsim (&start, %eval(&year+5))
%end;
%mend loop;
%loop(2010, 2060);
But the do statement increases by 1 while I want by 5;
If you want an increment other than 1, use
%by
If you want an increment other than 1, use
%by
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.