Chapter Contents

Previous

Next
The FREQ Procedure

Example 2: Computing Chi-Square Tests for One-Way Frequency Tables


Procedure features:
PROC FREQ statement option:
ORDER=
BY statement
TABLES statement options:
NOCUM
TESTP=
WEIGHT statement
Other features:
SORT procedure
Data set: COLOR

This example

The chi-square goodness-of-fit test examines whether the children's hair color has a specified multinomial distribution for two regions. The hypothesized distribution for hair color is 30 percent fair, 12 percent red, 30 percent medium, 25 percent dark, and 3 percent black.


Program

options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
proc sort data=color;
   by region;
run;
 Note about code
proc freq data=color order=data;
   weight count;
 Note about code
   tables hair/nocum testp=(30 12 30 25 3);
 Note about code
   by region;
 Note about code
   title 'Hair Color of European Children';
run;


Output
The frequency table lists the variable values (hair color) in the order that they appear in the data set. The last column lists the hypothesized percentages for the chi-square test. Always check that you have ordered the TESTP= percentages to correctly match the order of the variable levels.

PROC FREQ computes a chi-square statistic for each region. The chi-square statistic is significant at the .05 level for region 2 (p<=.05) but not for region 1, indicating a significant departure from the hypothesized percentages in region 2.

[HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.