BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sinistrum
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

 

 

 

Wrap your calculation in %eval().

 

 

%let s = %eval(&j. - 1);

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

 

 

 

Wrap your calculation in %eval().

 

 

%let s = %eval(&j. - 1);

 

 

Sinistrum
Quartz | Level 8

Thank you very much indeed - I do not now, how long I carried around this issue, but, finally, it is resolved.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2 replies
  • 1006 views
  • 1 like
  • 2 in conversation