1# wkn1986
data a;
input z x c v b n m;
cards;
1 2 3 4 5 6 7
5 6 7 8 9 0 1
;
run;
options mprint;
%macro rename(lib,dsn,new);
proc sql noprint;
select nvar into :num_vars
from dictionary.tables
where libname="%upcase(&LIB)" and memname="%upcase(&DSN)";
select distinct(name) into :var1-:var%trim(&num_vars)
from dictionary.columns
where libname="%upcase(&LIB)" and memname="%upcase(&DSN)";
quit;
run;
proc datasets library=&lib;
modify a;
rename
%do i=1 %to &num_vars;
&&var&i=&new&i
%end;
;
run;
%mend;
%rename(work,a,x)