SUMBY variables;
The SUMBY statement produces consolidation tables for variables whose names are in the SUMBY list. Only one SUMBY statement can be used.
To use a SUMBY statement, you must use a BY statement. The SUMBY and BY variables must be in the same relative order in both statements. For example:
by a b c; sumby a b;
This SUMBY statement produces tables that consolidate over values of C within levels of B and over values of B within levels of A. Suppose A has values 1, 2; B has values 1, 2; and C has values 1, 2, 3. Table 10.2 indicates the consolidation tables produced by the SUMBY statement.
Table 10.2: Consolidation Tables Produced by the SUMBY Statement
SUMBY Consolidations |
Consolidated BY Groups |
||
A=1, B=1 |
C=1 |
C=2 |
C=3 |
A=1, B=2 |
C=1 |
C=2 |
C=3 |
A=1 |
B=1, C=1 |
B=1, C=2 |
B=1, C=3 |
B=2, C=1 |
B=2, C=2 |
B=2, C=3 |
|
A=2, B=1 |
C=1 |
C=2 |
C=3 |
A=2, B=2 |
C=1 |
C=2 |
C=3 |
A=2 |
B=1, C=1 |
B=1, C=2 |
B=1, C=3 |
B=2, C=1 |
B=2, C=2 |
B=2, C=3 |
Two consolidation tables for B are produced for each value of A. The first table consolidates the three tables produced for the values of C while B is 1; the second table consolidates the three tables produced for C while B is 2.
Tables are similarly produced for values of A. Nested consolidation tables are produced for B (as described previously) for each value of A. Thus, this SUMBY statement produces a total of six consolidation tables in addition to the tables produced for each BY group.
To produce a table that consolidates the entire data set (the equivalent of using PROC COMPUTAB with neither BY nor SUMBY statements), use the special name _TOTAL_ as the first entry in the SUMBY variable list. For example,
sumby _total_ a b;
PROC COMPUTAB then produces consolidation tables for SUMBY variables as well as a consolidation table for all observations.
To produce only consolidation tables, use the SUMONLY option in the PROC COMPUTAB statement.