Nesting Categorical Variables

This example uses the data file survey_sample.sav. See the topic Sample Files for more information.

Nesting, like crosstabulation, can show the relationship between two categorical variables, except that one variable is nested within the other in the same dimension. For example, you could nest Gender within Age category in the row dimension, showing the number of males and females in each age category.

  1. Open the table builder (Analyze menu, Tables, Custom Tables).
  2. Click Reset to delete any previous selections in the table builder.
  3. In the table builder, drag and drop Age category from the variable list to the Rows area on the canvas pane.
  4. Drag and drop Gender from the variable list to the right of Age category in the Rows area.

    The preview on the canvas pane now shows that the nested table will contain a single column of counts, with each cell containing the number of males or females in each age category.

    You may notice that the variable label Gender is displayed repeatedly, once for each age category. You can minimize this kind of repetition by placing the variable with the fewest categories at the outermost level of the nesting.

  5. Click the variable label Gender on the canvas pane.
  6. Drag and drop the variable as far to the left in the Rows area as you can.

    Now instead of Gender being repeated six times, Age category is repeated twice. This is a less-cluttered table that will produce essentially the same results.

  7. Click OK to create the table.
Figure 1. Table of Age category nested within Gender
Table of Age category nested within Gender

Note: Custom Tables do not honor layered split file processing. To achieve the same result as layered split files, place the split file variables in the outermost nesting layers of the table. For more information of split file processing, see Split file.