BookmarkSubscribeRSS Feed
RajasekharReddy
Fluorite | Level 6

hi all,

how to rename more then two data sets in work Library by using macro

reagrds,

Rajasekhar Reddy 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Can you clarify why you need to use a macro, and why you would need to rename a dataset?

data new_dataset; set old_dataset; run;

If following a pattern then:

data _null_;

     set sashelp.vtable (where=(libname="XYZ" and substr(memname ,1,3)="ABC"));

     call exexcute('data DEF_'||strip(memname,4)||'; set ABC_'||strip(memname,4)||'; run;');

run;

This will rename every dataset in XYZ with the prefix ABC to have the prefix DEF.

Ksharp
Super User

No need Macro.

data _null_;
 set sashelp.vmember(where=(libname='WORK' and memtype='DATA')) end=last;
if _n_ eq 1 then call execute('proc datasets library='||libname||' nolist nodetails; change ');
call execute(strip(memname)||'=want'||strip(_n_));
if last then call execute(';quit;');
run;




Xia Keshan

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 choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 885 views
  • 0 likes
  • 3 in conversation