Dear community,
I would like to ask for your help, concerning the following issue:
The scenario is, that I am running a macro-%DO-loop.
What I do want to do is, to reference the “previous” step, which is to say, that, if my loop run from 1 to 5 and I am at point 4, I do want to create a macro variable, containing the value 3.
I have tried the following, but sadly, it does not work:
%macro doloop;
%DO j=1 %TO 5;
data interim; incr = &j.-1; run;
data _null_; set pft; call symput("s", interim); run;
data no_&j.; test=&j.; run;
data no_&s.; test=&s.; run;
%End;
%mend doloop;
%doloop;where j is the indicator of the loop and s is the "minus 1" variable.
I would be glad, if you could help me with this issue of mine.
Yours sincerely,
Sinistrum
Wrap your calculation in %eval().
%let s = %eval(&j. - 1);
Thank you very much indeed - I do not now, how long I carried around this issue, but, finally, it is resolved.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.