Creating Two-Way Tables

As noted earlier, you often want statistics for grouped data. It is possible to crosstabulate frequencies of two or more 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 an asterisk (*) in the TABLES statement of a PROC FREQ step.
Syntax, TABLES statement for crosstabulation:
TABLES variable-1 *variable-2 <* ... variable-n>;
Here are the options for two-way tables:
  • variable-1 specifies table rows.
  • variable-2 specifies table columns.
When crosstabulations are specified, PROC FREQ produces tables with cells that contain the following frequencies:
  • cell frequency
  • cell percentage of total frequency
  • cell percentage of row frequency
  • cell percentage of column frequency
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;
Figure 9.16 Two-Way Table Created by PROC FREQ
wo-Way Table Created by PROC FREQ
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.
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.113.163