Computing Frequency Distributions |
Creating
Crosstabulations |
Two-Way Tables
So far, you have used the FREQ procedure to create one-way tables of frequency. 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. Census data, for example, is typically crosstabulated with a variable representing 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, Height , forms the columns; reversing the order
of the TABLES statement would reverse their positions in the table. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.