1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
DATA test1 test2 test3;
SET sashelp.class;
run;
%macro rename ( table,mv_num);
proc sql noprint;
SELECT name, max (monotonic()) INTO: old_var separated BY ',' ,: nbr
FROM dictionary.COLUMNS WHERE upcase(libname)='WORK' AND upcase(memname)="&table" ;
quit;
DATA &table. ;
SET &table. ;
%do i=1 %TO &nbr.;
rename %scan("&old_var",&i,",")=%sysfunc(cats(&mv_num.,%scan("&old_var",&i,",")));
%end;
run;
%mend;
%rename ( TEST1, _01_);
%rename ( TEST2, _02_);
%rename ( TEST3, _03_); |
Partager