Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Rename data set

Reply
Contributor
Posts: 31

Rename data set

hi all,

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

reagrds,

Rajasekhar Reddy 

Super User
Super User
Posts: 7,977

Re: Rename data set

Posted in reply to RajasekharReddy

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.

Super User
Posts: 10,041

Re: Rename data set

Posted in reply to RajasekharReddy

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

Ask a Question
Discussion stats
  • 2 replies
  • 311 views
  • 0 likes
  • 3 in conversation