BookmarkSubscribeRSS Feed
scify
Obsidian | Level 7

I have a series of macro variables named &x_(year) that I need to perform some year-specific calculations.  Is there a way to combine the do loop variable with the &x_ stem to make sure everything matches up properly, or do I need to separate everything out into different steps?

1 REPLY 1
Tom
Super User Tom
Super User

Not sure what your question is but does using && help?

%macro test;

%do year=2010 %to 2011 ;

   %put year=&year x_&year=&&x_&year;

%end;

%mend test ;

%let x_2010=Value for 2010;

%let x_2011=Value for 2011;

%test;

year=2010 x_2010=Value for 2010

year=2011 x_2011=Value for 2011

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 654 views
  • 0 likes
  • 2 in conversation