College of Natural Sciences
 
FAQs
This is for IE7 to hold div open

SAS FAQ #10: SAS chi-square test of independence and the phi coefficient

Question:

I need to generate a chi-square test of independence using SAS, and I also need to get the phi coefficient. My frequencies are stored in a separate variable.

Answer:

Both the chi-square test of independence and the phi coefficient are output by SAS PROC FREQ.

The example SAS program below illustrates how to use PROC FREQ to obtain both the chi-square test for independence and the phi coefficient when the cell frequencies are stored in a variable.

DATA one ;
INPUT v1 v2 count ;
CARDS ;
0 0 1
1 0 3
0 1 11
1 1 25
;
* "Count" is the weighting variable containing cell sizes.;

PROC FREQ ;
WEIGHT count ;
TABLES v1*v2
    / CHISQ MEASURES ;
TITLE ' V1 by V2 Chi-Square Test and Phi Coefficient';
RUN;

The instream data contain three variables: V1, V2, and COUNT. Both V1 and V2 have only two possible values, 0 and 1 . Thus, the V1-by-V2 contingency table will be a 2-by-2 table.

The COUNT variable indicates the actual frequencies which appear in each cell of the 2-by-2 table. This is specified in the PROC FREQ by the WEIGHT statement. The TABLES statement specifies how the contingency table is to be built. The two variables which will produce the table are listed with an asterisk (*) between them. The first variable defines the rows of the table, the second defines the columns. Several chi-square based tests of independence and measures of association are requested by the option CHISQ.

For more information, click on the Help button in the SAS menu bar and scroll to SAS Help and Documentation.

If you have further questions, send E-mail to stats@ssc.utexas.edu.