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

I run the data and got the results as following:

 

Original 2015 Average Allowed Amount

Projected 2017 Allowed Amount

Projected Percent Change

$22,768.81

$22,762.06

-0.03%

We have new data next year and I want to run the new data, but the years have to be updated into "2016" and "2018" respectively. The "

Original 2015 Average Allowed Amount" and "Projected 2017 Allowed Amount" are variable names in my data. I don't want to manually change the variable names each year. I tried to define macro variable names to update the years automatically, but I failed. Any ideas, suggestions and recommendations will be greatly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
mbuchecker
Quartz | Level 8

Hi, you have a few options depending on what you want. You could say:

%let year=2018;

%let prev=%eval(&year-2);

title "Original &prev Average Allowed Amount" and "Projected &year Allowed Amount";

 

Then just change the first statement as needed.

 

Or if you know it is one year in the future and one year in the past.

%let next=%eval(%substr(&sysdate9, 6, 4)+1);

%let prev=%eval(&next-2);

title "Original &prev Average Allowed Amount" and "Projected &next Allowed Amount";

 

Michelle

View solution in original post

5 REPLIES 5
mbuchecker
Quartz | Level 8

Hi, you have a few options depending on what you want. You could say:

%let year=2018;

%let prev=%eval(&year-2);

title "Original &prev Average Allowed Amount" and "Projected &year Allowed Amount";

 

Then just change the first statement as needed.

 

Or if you know it is one year in the future and one year in the past.

%let next=%eval(%substr(&sysdate9, 6, 4)+1);

%let prev=%eval(&next-2);

title "Original &prev Average Allowed Amount" and "Projected &next Allowed Amount";

 

Michelle
zhuxiaoyan1
Quartz | Level 8

Thank you!

art297
Opal | Level 21

It would help if you showed the code you tried and indicated what you're actual variable names are. Do they "really" have spaces in them, or are those just the variable labels?

 

Art, CEO, AnalystFinder.com

 

ballardw
Super User

You may need to show your existing code to make suggestions pointed to specific items of your existing code.

 

Since "Original 2015 Average Allowed Amount" is definitely not a normal SAS variable name details could be critical to getting working code.

zhuxiaoyan1
Quartz | Level 8

Yes, you are right. They are labels, not variable names. Sorry about this confusion. I used mbuchecker's code and added label statement and got it fixed. Thank you for your input!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1044 views
  • 0 likes
  • 4 in conversation