The TABULATE Procedure

Example 12: Calculating Various Percentage Statistics

Procedure features:
PROC TABULATE statement options:
 FORMAT=
TABLE statement:

 ALL class variable COLPCTSUM statistic concatenation (blank operator) crossing (* operator) format modifiers grouping elements (parentheses operator) labels REPPCTSUM statistic ROWPCTSUM statistic variable list

TABLE statement options:
 ROW=FLOAT RTS=
Other features: FORMAT procedure

This example shows how to use three percentage sum statistics: COLPCTSUM, REPPCTSUM, and ROWPCTSUM.
 ```options nodate pageno=1 linesize=105 pagesize=60; data fundrais; length name \$ 8 classrm \$ 1; input @1 team \$ @8 classrm \$ @10 name \$ @19 pencils @23 tablets; sales=pencils + tablets; cards; BLUE A ANN 4 8 RED A MARY 5 10 GREEN A JOHN 6 4 RED A BOB 2 3 BLUE B FRED 6 8 GREEN B LOUISE 12 2 BLUE B ANNETTE . 9 RED B HENRY 8 10 GREEN A ANDREW 3 5 RED A SAMUEL 12 10 BLUE A LINDA 7 12 GREEN A SARA 4 . BLUE B MARTIN 9 13 RED B MATTHEW 7 6 GREEN B BETH 15 10 RED B LAURA 4 3 ;```
 ```proc format; picture pctfmt low-high='009 %'; run;```
 `title "Fundraiser Sales";`
 `proc tabulate format=7.;`
 ``` class team classrm; var sales;```
 ` table (team all)*sales=' ',`
 ``` classrm='Classroom'*(sum colpctsum*f=pctfmt9. rowpctsum*f=pctfmt9. reppctsum*f=pctfmt9.) all```
 ``` /rts=20 row=float; run;```

Here are the percentage sum statistic calculations used to produce the output for the Blue Team in Classroom A:
 COLPCTSUM=31/91*100=34% ROWPCTSUM=31/67*100=46% REPPCTSUM=31/204*100=15%
Similar calculations were used to produce the output for the remaining teams and classroom.