Hello everyone,
I have a very wide dataset with 229 variables.
I am trying to change thoese variables' names into an enumerated sequence such that my final result will look like so:
sq_1 sq_2 sq_3.... sq_227.
I tried this macro but it failed:
%macro rename(lib,dsn,newname); proc contents data=&lib..&dsn; title 'before renaming'; run; proc sql noprint; %rename(WORK,call_qs1); from dictionary.tables where libname="&LIB" and memname="&DSN"; select distinct(name) into :var1-:var%trim(%left(&num_vars)) from dictionary.columns where libname="&LIB" and memname="&DSN"; quit; run; proc datasets library = &LIB; modify &DSN; rename %do i = 1 %to &num_vars.; &&var&i = &sq._&i. %end; ; quit; run; proc contents data=&lib..&dsn.; title 'after renaming'; run; %mend rename;
%rename(WORK,call_qs1,call_qs2);
As always, Thank you for your help.
... View more