Hi:
Maybe this will give you an idea of computing a cumulative variable and a percent of total versus a percent of a group. We use an example similar to this in our report class.
[pre]
** make some data with only a few products and regions;
proc sort data=sashelp.shoes out=shoes;
by region product;
where region in ('Asia', 'Canada', 'Pacific') and
product in ('Boot', 'Slipper', 'Sandal');
run;
options missing = ' ';
ods html file='cum_grppct.html' style=sasweb;
proc report data=shoes nowd ;
title '2) Percent PROC REPORT';
title2 'Calculated with Temporary Variables';
column region
product sales PctGrp cumsales sales=psal;
define region / group 'Region' f=$25.;
define product / group 'Product';
define sales / sum 'Sales' f=comma14.;
define cumsales / computed 'Cum Sales' f=comma14.;
define pctgrp / computed 'Percent of Region' f=percent9.2;
define psal / pctsum 'Percent of Total' f=percent9.2;
break after region / summarize;
rbreak after / summarize;
compute before region;
grptot=sales.sum;
holdsales = 0;
endcomp;
compute PctGrp;
PctGrp=sales.sum / grptot;
endcomp;
compute cumsales;
holdsales + sales.sum;
if _break_ = ' ' then cumsales = holdsales;
else cumsales = sales.sum;
endcomp;
compute after region /
style=Header;
line ' ';
endcomp;
compute after;
PctGrp = .;
region = 'Overall Report';
endcomp;
run;
ods _all_ close;
[/pre]
This report uses some temporary variables to accumulate cum sales and for calculating the percent of group. This is getting into some advanced PROC REPORT topics. You might want to read the section in the PROC REPORT documentation on how PROC REPORT performs processing to build a report:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a002473631.htm
In addition, some other documentation which you might find helpful are papers by Art Carpenter on PROC REPORT and the COMPUTE block or Technical Report P-258, about using PROC REPORT in "batch" on non-interactive mode:
http://support.sas.com/documentation/onlinedoc/v82/techreport_p258.pdf (even though this is older documentation, it is still good PROC REPORT information.
cynthia