Sas 过程报告:集团总额的比例
我有以下过程报告Sas 过程报告:集团总额的比例,sas,grouping,proc-report,Sas,Grouping,Proc Report,我有以下过程报告 proc report data=sashelp.class; col sex age weight ; define sex / group; define age / group; define weight / analysis sum; run; 但是我不想显示重量的总和。相反,我希望得到分组总和的比例。所以第一行应该是6.23%。如何实现这一点?现在我找到了一个解决方法: proc sql noprint; CREATE
proc report data=sashelp.class;
col
sex
age
weight
;
define sex / group;
define age / group;
define weight / analysis sum;
run;
但是我不想显示重量的总和。相反,我希望得到分组总和的比例。所以第一行应该是6.23%。如何实现这一点?现在我找到了一个解决方法:
proc sql noprint;
CREATE TABLE class AS
SELECT a.*
,b.sumweight
FROM sashelp.class a
LEFT JOIN (SELECT sex, sum(weight) as sumweight
FROM sashelp.class
GROUP BY sex
) b
ON a.sex=b.sex
;
quit;
proc report data=class;
col
sex
age
weight
sumweight
perc
;
define sex / group;
define age / group;
define weight / analysis sum;
define sumweight / analysis mean noprint;
define perc / computed format=percent6.2;
compute perc;
perc = weight.sum/sumweight.mean;
endcomp;
run;
但也许有一个解决方案没有额外的过程sql步骤