BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

User define 2 macro variables

%let minYYMM=2007;

%let maxYYMM=2106;

 

I want to create another macro variable called List that will get YYMM  values between &minYYMM and &maxYYMM.

So in this case the desired value of the new macro variable  is  2007+2008+2009+2010+2011+2012+2101+2102+2103+2104+2105+2106

 

 

Thanks

 

1 REPLY 1
Kurt_Bremser
Super User

Use a DO loop with INTNX:

data _null_;
length vector $32767;
start = input("20&minyymm.01",yymmdd10.);
do while (start le input("20&maxyymm.01",yymmdd8.));
  vector=catx("+",vector,substr(put(start,yymmddn8.),3,4));
  start = intnx('month',start,1);
end;
call symputx("vector",vector);
run;

This loop can be used to directly create repeated code with CALL EXECUTE or similar.

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
  • 317 views
  • 0 likes
  • 2 in conversation