BookmarkSubscribeRSS Feed
renjithr
Quartz | Level 8

Hi,

 

Could you please let me know how I can conditionally rename a dataset?

 

eg: I have dataset TEST in a library.

 

So if the run month=01 then I need to rename TEST to TEST_01.

5 REPLIES 5
ballardw
Super User

What rule are you using to determine that the "run month = 01"?

And since this is a date related question what do you want to do the following year when there is another "run month=01"?

Are also asking "how do I determine if the data set TEST exists in the library I expect it to?"

 

renjithr
Quartz | Level 8

Hi,

 

I set the macro variable , for eg: mth according to the date when I run the program.

So I plan to run the process only on the month of January all other months are not affected.

Data set should be avaialbe in the library from the previous months run.

 

Thank you!

SuryaKiran
Meteorite | Level 14

I'm not sure how much I undesstood your problem.

 

%let month= %sysfunc(month("&sysdate"d));

data TEST_&month;

set TEST;

run;

Thanks,
Suryakiran
renjithr
Quartz | Level 8

Hi,

 

The dataset I want to rename is in a permanent library and I want to rename that dataset only in January.

 

Ksharp
Super User
data test;
 set sashelp.class;
run;

proc datasets library=work nodetails nolist;
 change test=test_%sysfunc(month(%sysfunc(today())));
quit;

 

 

data test;
 set sashelp.class;
run;

%let month=01;
proc datasets library=work nodetails nolist;
 change test=test_&month;
quit;

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1204 views
  • 0 likes
  • 4 in conversation