BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
How to rename?
I'm having difficulty to switch year i.e 2011 to 2010

Input date: 201104.

This date is used to rename everymonth vars sls1-sls24 as:
Sls1 to SLS201104
Sls2 to SLS201103
Sls3 to SLS201102
.
.
.SLS24

The nextmonth
Input date: 201105.

Sls1 to SLS201105 so on
1 REPLY 1
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello SASPhile,

This is a solution for a next chapter of your renaming saga:
[pre]
%macro a(d0);
%global r;
%let r=rename;
%let m=%SYSFUNC(MOD(&d0,100));
%let y=%SYSFUNC(INT(&d0/100));
%put m=&m y=&y;
%let j=&d0;
%do i=1 %to 24;
%let r=&r SK&i=SLS&j;
%let m=%EVAL(&m-1);
%if &m = 0 %then %do; %let y=%EVAL(&y-1); %let m=12; %end;
%if &m LT 10 %then %let j=&y.0&m;
%else %let j=&y.&m;
%end;
%mend a;
%a(201104);
%put r=&r;
[/pre]
Sincerely,
SPR

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 735 views
  • 0 likes
  • 2 in conversation