Group Processing Using the CLASS Statement

You will often want statistics for grouped observations, instead of for observations as a whole. For example, census numbers are more useful when grouped by region than when viewed as a national total. To produce separate analyses of grouped observations, add a CLASS statement to the MEANS procedure.


General form, CLASS statement:
CLASS variable(s);

where variable(s) specifies category variables for group processing.


PROC MEANS does not generate statistics for CLASS variables, because their values are used only to categorize data. CLASS variables can be either character or numeric, but they should contain a limited number of discrete values that represent meaningful groupings.

The output of the program shown below is categorized by values of the variables Survive and Sex. The order of the variables in the CLASS statement determines their order in the output table.

     proc means data=clinic.heart maxdec=1;
        var arterial heart cardiac urinary;
        class survive sex;
     run;

Survive Sex N Obs Variable N Mean Std Dev Minimum Maximum
DIED 1 4 Arterial
Heart
Cardiac
Urinary
4
4
4
4
92.5
111.0
176.8
98.0
10.5
53.4
75.2
186.1
83.0
54.0
95.0
0.0
103.0
183.0
260.0
377.0
  2 6 Arterial
Heart
Cardiac
Urinary
6
6
6
6
94.2
103.7
318.3
100.3
27.3
16.7
102.6
155.7
72.0
81.0
156.0
0.0
145.0
130.0
424.0
405.0
SURV 1 5 Arterial
Heart
Cardiac
Urinary
5
5
5
5
77.2
109.0
298.0
100.8
12.2
32.0
139.8
60.2
61.0
77.0
66.0
44.0
88.0
149.0
410.0
200.0
  2 5 Arterial
Heart
Cardiac
Urinary
5
5
5
5
78.8
100.0
330.2
111.2
6.8
13.4
87.0
152.4
72.0
84.0
256.0
12.0
87.0
111.0
471.0
377.0