Chapter Contents

Previous

Next
The FREQ Procedure

Example 5: Creating an Output Data Set Containing Chi-Square Statistics


Procedure features:
PROC FREQ statement option:
ORDER=
OUTPUT statement options:
OUT=
statistic-keywords
TABLES statement options:
CHISQ
DEVIATION
EXPECTED
NOCOL
NOROW
WEIGHT statement
Other features:
PRINT procedure
Data set: COLOR

This example


Program
 Note about code
options nodate pageno=1 pagesize=60;

proc freq data=color order=data;
   weight count;
 Note about code
   tables eyes*hair /chisq expected cellchi2
                     norow nocol;
 Note about code
   output out=chisqdat pchi lrchi n nmiss;
   title 'Chi-Square Tests for 3 by 5 Table of Eye and Hair Color';
run;
 Note about code
proc print data=chisqdat noobs;
   title 'Chi-Square Statistics for Eye and Hair Color';
   title2 'Output Data Set from the FREQ Procedure';
run;


Output
The contingency table lists eye and hair color in the order that they appear in the data set. The first column label explains the contents of each table cell. The Pearson chi-square provides evidence of an association between eye and hair color (p=.007). The cell chi-square values show that most of the association is due to more green-eyed children with fair or red hair and fewer with dark or black hair. Exactly the opposite occurs with the brown-eyed children. [HTML Output]
 [Listing Output]
The output data set has one observation that contains the sample size, number of missing observations, and chi-square statistics with the corresponding degrees of freedom and probability values. [HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

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