|
自己的问题自己回复
万分感谢crackman,是看了他的帖子‘跟crackman读sas程序(106)—批量修改变量名’改的。
data list;
input aaa adtc bdtc cdtc ddtc edtc@@;
datalines;
0 1 2 3 4 5
;
run;
ods listing close;
ods output position = temp;
proc contents data = list varnum;
run;
ods listing;
data temp;
set temp;
if upcase(substr(strip(reverse(variable)), 1, 3))='CTD' then var=reverse(substr(strip(reverse(variable)), 4));
if ^missing(var);
run;
proc sql noprint;
select put(count(num), 1.) into :num from temp;
select strip(var) into :var1-:var&num. from temp;
quit;
%macro final;
data list_final;
set list;
%do i=1 %to #
%let j=&&var&i.;
&j.dt=put(&j.dtc, z2.);
%end;
run;
%mend;
%final;
|