BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ccaudillo100
Obsidian | Level 7

Hello,  I am trying to see if there is a way to set Parameters based off of other Parameters. 

Currently I use:

%Let RY=23;

 

I would like to set 

%Let RY1 =22;

%Let RY2 =21;

etc. for 10 more years. 

 

but instead of manually changing every single one of them at the start of a new year, I was wanting to see if I could set it to be something like

%Let RY=23;

%Let RY1 = RY-1; so when it plugs in RY1 it will place 22.

 

Thanks in advanced!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
%let ry1=%eval(&ry-1);

However, as alluded to by @ballardw , it may be a better idea to discuss the context on how this will be used, as perhaps we can provide even better solutions if we know the broader context.

--
Paige Miller

View solution in original post

2 REPLIES 2
ballardw
Super User

If you show more of what you are attempting it may help.

 

I would suggest that if the values you want are in sequence to use a macro with a loop.

%macro somename (start=, end=);
% do Ry=&start %to &end;

<other code- suffix final output if needed with value of &ry to distinguish>

%end;
%mend;

%somename (start=21, end=31)

You can use %eval function to force INTEGER arithmetic with macro values %let var = %eval(&othervar - 1); If the values are decimals the use %sysevalf.

PaigeMiller
Diamond | Level 26
%let ry1=%eval(&ry-1);

However, as alluded to by @ballardw , it may be a better idea to discuss the context on how this will be used, as perhaps we can provide even better solutions if we know the broader context.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 287 views
  • 1 like
  • 3 in conversation