e*******e 发帖数: 75 | 1 Hi,
I am wondering who knows how to remove all the underscore in the variable
name? I have a data set with more than 200 variables and most of them have
more than one underscores. Is there any way to automatically rename all the
variables (removing the underscores in all of the variables in the data set)
instead of rename them one by one?
Many thanks! | B****N 发帖数: 440 | 2 教你一个简单的笨办法。
1,用proc contents打出variable names;
2,拷贝到excel里,替换掉下划线;
3,然后再data step里rename.
用SAS本身也能做,但如果你只做这一次的话,这个更省时间。 | k*******a 发帖数: 772 | 3 写了隔macro你试试看
%macro rename(lib=,data=);
proc sql;
select strip(name)||'='||compress(name,'_') into :rename separated by ' '
from sashelp.vcolumn
where upcase(libname)=upcase("&lib") and upcase(memname)=upcase("&data");
quit;
data new;
set &lib..&data;
rename &rename;
run;
%mend; | e*******e 发帖数: 75 | |
|