Hi:
As much as I love PROC REPORT, I'm tempted to give this one to PROC TABULATE to produce the report. The ability to calculate percentages is very straightforward with TABULATE and usually produces the percentage you want either with a keyword percentage (ROWPCTSUM, COLPCTSUM, etc) or with a demoninator definition <denom> specified in the TABLE statement. PROC REPORT will do the job, but it does require some extra coding above and beyond basic PROC REPORT coding.
The only thing that TAB does that takes some getting used to is that it does an automatic multiply by 100 for percentages, which means that you cannot use the SAS pre-defined percent format. But with a PICTURE format, you can fix that easily and get a % into your cells. For example, given the data shown above, the TABULATE code would be as shown below. The PROC FORMAT step is defining a PICTURE format for use in the TABLE statement *f=pct. crossing, otherwise, the comma8 format will be used for all the other cells.
cynthia
[pre]
data getpct;
infile datalines;
input stage $ x y z total;
return;
datalines;
A 1 2 2 5
B 3 6 9 18
C 1 2 5 8
;
run;
proc format;
picture pct low-high='009.9%';
run;
ods listing close;
ods html file='c:\temp\getpct.html' style=sasweb;
proc tabulate data=getpct f=comma8.;
class stage;
var x y z total;
table stage all*pctsum*f=pct.,
x y z total / row=float;
keylabel sum=' '
pctsum = ' '
all='Percent';
run;
ods html close;
[/pre]