data test;
length ctr $25.;
infile datalines;
input ctr $ cnt cnt2;
return;
datalines;
4411 5 15
4455 15 66
4466 6 666
4477 11 42
;
run;
proc report = test nowd style(summary)=Header;
title 'test';
column ctr cnt cnt2 RTot PctTot;
define ctr /order order=data style (column)=Header ;
define cnt /sum f=comma6.;
define cnt2 /sum f=comma6.;
define PctTot/computed f=percent8.2;
define RTot /computed f=comma16. "Row Totals";
compute RTot;
RTot=sum(cnt.sum,cnt2.sum);/*row_tot*/
endcomp;
compute before;
sum=cnt.sum;
endcomp;
compute PctTot;
pcttot=cnt.sum/sum;
endcomp;
compute after;
ctr='Total';
endcomp;
rbreak after /summarize;
run;
It produces the results below. I want the PCTTOT to be a measure of the cnt2/RTOT so for the first entry it should be 15/20 = 0.75 or 75% So essentially I want to calculate at the row level across
| 5 |
15 |
20 |
13.51% |
| 15 |
66 |
81 |
40.54% |
| 6 |
666 |
672 |
16.22% |
| 11 |
42 |
53 |
29.73% |