data temp;
set stuff;
length sumname $14.;
sumname=cats(name,'_total'); /*给每一个变量名字添加后缀_total,以示区别初始变量的名字*/
run;
/* look at new name */
proc print data=temp;
title 'temp';
run;
title;
/* create macro var with list of numeric variable names */
proc sql;
select (sumname)
into utname separated by ' ' /*将添加后缀和原始变量的名字一次赋值给宏变量*/
from temp
where type = 1;
select (name)
into :inname separated by ' '
from temp
where type = 1;
quit;
proc means data=sashelp.class;
var &inname;
output out=mymeans sum= &outname; /*计算每一个变量的汇总*/
run;
proc print data=mymeans;
title 'mymeans';
run;