%macro rnm(data=,out=); proc contents data=&data out=t1(keep=varnum name) noprint; run; proc sql noprint; select name into :classname separated by‘ ‘ from t1 order by varnum; quit; %put &classname; data &out; set &data; %let i=1; %do %until (%scan(&classname.,&i.," ")=); %let yn=%sysfunc(compress(%scan("&classname",&i," "))); rename &yn=C&i; %let i=%eval(&i.+1); %end; proc datasets nolist; delete t1; run; %mend; /*调用*/ %rnm(data=test1,out=test2); /*去除所有label*/ proc datasets lib=output noprint; attrib _all_ label=‘‘; run;
适用于:数据集字段需要批处理,且字段名称无规律,统一rename后方便后续操作。
原文地址:https://www.cnblogs.com/jiulaosan/p/10729468.html
时间: 2024-10-09 02:04:33