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-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 710 views
  • 1 like
  • 3 in conversation