wwang111 发表于 2014-3-26 14:45 
proc transpose data=a out=b(rename=(_name_=var));
var _numeric_;
run;
First doing the sum and second transposing the results. This will be more efficient.
You can do it within ONE data step.
data t1;
array x(*) a b c d e f g h j k;
do _i_=1 to 20;
do _j_=1 to dim(x);
x(_j_)=rannor(123)>0;
end;
output;
end;
keep a b c d e f g h j k;
run;
data t2;
set t1 end=end;
array x(*) a b c d e f g h j k;
array sx(*) sa sb sc sd se sf sg sh sj sk;
retain sa sb sc sd se sf sg sh sj sk;
do _j_=1 to dim(x);
sx(_j_)+x(_j_);
end;
if end then do;
do _j_=1 to dim(x);
name=vname(x(_j_));
count=sx(_j_);
output;
end;
end;
keep name count;
run;
proc print;run;
proc means data=t1 noprint;
var a b c d e f g h j k;
output out=sum sum=;
run;
proc transpose data=sum out=t3(rename=(_name_=name col1=count));
var a b c d e f g h j k;
run;
proc print;run;