So far, you have used the FREQ procedure to create one-way frequency tables. The table results show total frequency counts for the values within the data set. However, it is often helpful to crosstabulate frequencies with the values of other variables. For example, census data is typically crosstabulated with a variable that represents geographical regions. The simplest crosstabulation is a two-way table. To create a two-way table, join two variables with asterisks (*) in the TABLES statement of a PROC FREQ step. |
General form, TABLES statement for crosstabulation:
where (for two-way tables)
|
When crosstabulations are specified, PROC FREQ produces tables with
cells that contain
For example, the following program creates the two-way table shown below. proc format; value wtfmt low-139='< 140' 140-180='140-180' 181-high='> 180'; value htfmt low-64='< 5''5"' 65-70='5''5-10"' 71-high='> 5''10"'; run; proc freq data=clinic.diabetes; tables weight*height; format weight wtfmt. height htfmt.; run; |
|
|
Note that the first variable, Weight , forms the table rows,
and the second variable, Height , forms the columns; reversing
the order of the variables in the TABLES statement would reverse their
positions in the table. Note also that the statistics are listed in the
legend box. |