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-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
  • 5 replies
  • 788 views
  • 0 likes
  • 4 in conversation