proc sql;
create table tem as
select a,sum(a) as sum_a,a/sum(a) as percent format=percent10.2 from tem;
quit;[/code:7cdf5]作者: shiyiming 时间: 2004-5-24 21:17
万分感谢
//bow
[code:5ad76]data tem2;
do i=1 to 20;
A=int(ranuni(12345)*10);
output;
end;
run;
data tem2;
if _n_=1 then do until(last);
set tem2(keep=a) end=last;
Sum_a+a;
end;
set tem2;
Percent=A/Sum_a;
format percent percent10.2;
run;[/code:5ad76]
[code:84243]data tmp(keep=a);
do i=1 to 20;
a=int(ranuni(0)*10);
output;
end;
run;
proc means data=tmp noprint;
var a;
output out=asum(keep=total) sum=total;
run;
data tmp;
set tmp;
if _N_ = 1 then set asum;
percent=a/total;
format percent percent10.2;
run;[/code:84243]作者: shiyiming 时间: 2004-5-30 13:27
可以用macro来做:
data tmp(keep=a);
do i=1 to 20;
a=int(ranuni(0)*10);
output;
end;
run;
proc means noprint;
var a;
output out=sum_a sum=sum_a;
run;
data _null_;
set sum_a;
call symput('sum_a',sum_a);
run;