data baseball(keep=Team nAtBat nHits);
set sashelp.baseball;
if team in ('Cleveland','Houston','Seattle','Montreal');
run;
proc tabulate data= baseball;
class Team;
var nAtBat
nHits ;
Table Team =' ' all={label='Grand Total'
S=[background = lightblue cellwidth=80]}
*[STYLE=[Font_Weight=BOLD]],
nAtBat*(sum*f=comma15.)
nHits*(sum*f=comma15.);
label nAtBat = 'Total At Bats';
label nHits = 'Total Hits';
;run;
The proc tabulate prouduces the following. The objective is to get the percentage of hits to at bats and the bottomline average
Total At Bats
Total Hits
Sum
Sum
Cleveland
5,478
1,564
Houston
4,386
1,201
Montreal
4,539
1,216
Seattle
4,975
1,279
Grand Total
19,378
5,260
Desire to get the percentage of the total at bats
Total At Bats
Total Hits
Pct Hits to At bats
Sum
Sum
Cleveland
5,478
1,564
28.55%
Houston
4,386
1,201
27.38%
Montreal
4,539
1,216
26.79%
Seattle
4,975
1,279
25.71%
Grand Total
19,378
5,260
27.14%
... View more