Previous Page | Next Page

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.


Program

 Note about code
options nodate pageno=1 linesize=105 pagesize=60;
 Note about code
data fundrais;
   length name $ 8 classrm $ 1;
   input @1 team $ @8 classrm $ @10 name $
         @19 pencils @23 tablets;
   sales=pencils + tablets;
   datalines;
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
;
 Note about code
proc format;
   picture pctfmt low-high='009 %';
run;
 Note about code
title "Fundraiser Sales";
 Note about code
proc tabulate format=7.;
 Note about code
   class team classrm;
 Note about code
   var sales;
 Note about code
   table (team all),
 Note about code
         classrm='Classroom'*sales=' '*(sum
         colpctsum*f=pctfmt9.
         rowpctsum*f=pctfmt9.
         reppctsum*f=pctfmt9.)
         all*sales*sum=' '
 Note about code
         /rts=20;
run;

Output

                                            Fundraiser Sales                                            1

--------------------------------------------------------------------------------------------------------
|                  |                                 Classroom                                 |       |
|                  |---------------------------------------------------------------------------|       |
|                  |                  A                  |                  B                  |  All  |
|                  |-------------------------------------+-------------------------------------+-------|
|                  |  Sum  |ColPctSum|RowPctSum|RepPctSum|  Sum  |ColPctSum|RowPctSum|RepPctSum|  Sum  |
|------------------+-------+---------+---------+---------+-------+---------+---------+---------+-------|
|team              |       |         |         |         |       |         |         |         |       |
|------------------|       |         |         |         |       |         |         |         |       |
|BLUE              |     31|     34 %|     46 %|     15 %|     36|     31 %|     53 %|     17 %|     67|
|------------------+-------+---------+---------+---------+-------+---------+---------+---------+-------|
|GREEN             |     18|     19 %|     31 %|      8 %|     39|     34 %|     68 %|     19 %|     57|
|------------------+-------+---------+---------+---------+-------+---------+---------+---------+-------|
|RED               |     42|     46 %|     52 %|     20 %|     38|     33 %|     47 %|     18 %|     80|
|------------------+-------+---------+---------+---------+-------+---------+---------+---------+-------|
|All               |     91|    100 %|     44 %|     44 %|    113|    100 %|     55 %|     55 %|    204|
--------------------------------------------------------------------------------------------------------

A Closer Look

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 classrooms.

Previous Page | Next Page | Top of Page