Add Statistics to the Nested Variables

Overview

The previous examples showed how to add multiple class variables to your two-dimensional table. But often you want to add multiple statistics as well. So far, we have looked at means, but the tables would be more helpful if we could also see the number of observations for each subgroup. If there are only a few observations in some of the table cells, then the mean statistic becomes less useful.

Add the Statistics

The following code produces a table with the number of observations next to every mean. This is accomplished by using parentheses around the two statistics keywords N and MEAN.
PROC TABULATE DATA=TEMP;
   VAR INCOME;
   CLASS EDUC FULLTIME GENDER;
   TABLE EDUC*GENDER*(N MEAN), INCOME*FULLTIME; ...

Get PROC TABULATE by Example, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.