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!
%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.
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.
%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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.