Examples with contingency tables - YOURNAME 1 A simple 2x2 table with 4 entries 02:13 Thursday, September 8, 2005 The data as SAS sees it: Obs sex income num 1 M Rich 20 2 M Poor 10 3 F Rich 80 4 F Poor 90 Examples with contingency tables - YOURNAME 2 A simple 2x2 table with 4 entries 02:13 Thursday, September 8, 2005 (Two one-way tables followed by a 2x2 table) The FREQ Procedure Cumulative Cumulative sex Frequency Percent Frequency Percent -------------------------------------------------------- M 30 15.00 30 15.00 F 170 85.00 200 100.00 Cumulative Cumulative income Frequency Percent Frequency Percent ----------------------------------------------------------- Rich 100 50.00 100 50.00 Poor 100 50.00 200 100.00 Table of sex by income sex income Frequency| Percent | Row Pct | Col Pct |Rich |Poor | Total ---------+--------+--------+ M | 20 | 10 | 30 | 10.00 | 5.00 | 15.00 | 66.67 | 33.33 | | 20.00 | 10.00 | ---------+--------+--------+ F | 80 | 90 | 170 | 40.00 | 45.00 | 85.00 | 47.06 | 52.94 | | 80.00 | 90.00 | ---------+--------+--------+ Total 100 100 200 50.00 50.00 100.00 Examples with contingency tables - YOURNAME 3 A simple 2x2 table with 4 entries 02:13 Thursday, September 8, 2005 (Two one-way tables followed by a 2x2 table) The FREQ Procedure Statistics for Table of sex by income Statistic DF Value Prob ------------------------------------------------------ Chi-Square 1 3.9216 0.0477 Likelihood Ratio Chi-Square 1 3.9866 0.0459 Continuity Adj. Chi-Square 1 3.1765 0.0747 Mantel-Haenszel Chi-Square 1 3.9020 0.0482 Phi Coefficient 0.1400 Contingency Coefficient 0.1387 Cramer's V 0.1400 Fisher's Exact Test ---------------------------------- Cell (1,1) Frequency (F) 20 Left-sided Pr <= F 0.9859 Right-sided Pr >= F 0.0367 Table Probability (P) 0.0226 Two-sided Pr <= P 0.0734 Sample Size = 200 Examples with contingency tables - YOURNAME 4 The data as SAS sees it: 02:13 Thursday, September 8, 2005 2x2 table read using output commands Obs sex num1 num2 income count 1 M 20 10 Rich 20 2 M 20 10 Poor 10 3 F 80 90 Rich 80 4 F 80 90 Poor 90 Examples with contingency tables - YOURNAME 5 Data for a 2x5 table 02:13 Thursday, September 8, 2005 The data as SAS sees it: Obs sex num1 num2 num3 num4 num5 income count 1 F 10 12 19 17 20 1 10 2 F 10 12 19 17 20 2 12 3 F 10 12 19 17 20 3 19 4 F 10 12 19 17 20 4 17 5 F 10 12 19 17 20 5 20 6 M 20 15 12 14 10 1 20 7 M 20 15 12 14 10 2 15 8 M 20 15 12 14 10 3 12 9 M 20 15 12 14 10 4 14 10 M 20 15 12 14 10 5 10 Examples with contingency tables - YOURNAME 6 Data for a 2x5 table 02:13 Thursday, September 8, 2005 NOTE that the P-value for the `Mantel-Haenszel' test is MUCH MORE significant than the others. Can you see why? The FREQ Procedure Table of sex by income sex income Frequency| Percent | Row Pct | Col Pct | 1| 2| 3| 4| 5| Total ---------+--------+--------+--------+--------+--------+ F | 10 | 12 | 19 | 17 | 20 | 78 | 6.71 | 8.05 | 12.75 | 11.41 | 13.42 | 52.35 | 12.82 | 15.38 | 24.36 | 21.79 | 25.64 | | 33.33 | 44.44 | 61.29 | 54.84 | 66.67 | ---------+--------+--------+--------+--------+--------+ M | 20 | 15 | 12 | 14 | 10 | 71 | 13.42 | 10.07 | 8.05 | 9.40 | 6.71 | 47.65 | 28.17 | 21.13 | 16.90 | 19.72 | 14.08 | | 66.67 | 55.56 | 38.71 | 45.16 | 33.33 | ---------+--------+--------+--------+--------+--------+ Total 30 27 31 31 30 149 20.13 18.12 20.81 20.81 20.13 100.00 Statistics for Table of sex by income Statistic DF Value Prob ------------------------------------------------------ Chi-Square 4 8.5610 0.0731 Likelihood Ratio Chi-Square 4 8.6861 0.0694 Mantel-Haenszel Chi-Square 1 7.0135 0.0081 Phi Coefficient 0.2397 Contingency Coefficient 0.2331 Cramer's V 0.2397 Sample Size = 149 Examples with contingency tables - YOURNAME 7 The same 2x5 table using a SAS array 02:13 Thursday, September 8, 2005 with more explicit column headings The data as SAS sees it: Showing the variables sex colh count inc (income) only Obs sex colh count inc 1 F Lev1 10 1 2 F Lev2 12 2 3 F Lev3 19 3 4 F Lev4 17 4 5 F Lev5 20 5 6 M Lev1 20 1 7 M Lev2 15 2 8 M Lev3 12 3 9 M Lev4 14 4 10 M Lev5 10 5 Examples with contingency tables - YOURNAME 8 The same 2x5 table using a SAS array 02:13 Thursday, September 8, 2005 with more explicit column headings Table output: The FREQ Procedure Table of sex by colh sex colh Frequency| Percent | Row Pct | Col Pct |Lev1 |Lev2 |Lev3 |Lev4 |Lev5 | Total ---------+--------+--------+--------+--------+--------+ F | 10 | 12 | 19 | 17 | 20 | 78 | 6.71 | 8.05 | 12.75 | 11.41 | 13.42 | 52.35 | 12.82 | 15.38 | 24.36 | 21.79 | 25.64 | | 33.33 | 44.44 | 61.29 | 54.84 | 66.67 | ---------+--------+--------+--------+--------+--------+ M | 20 | 15 | 12 | 14 | 10 | 71 | 13.42 | 10.07 | 8.05 | 9.40 | 6.71 | 47.65 | 28.17 | 21.13 | 16.90 | 19.72 | 14.08 | | 66.67 | 55.56 | 38.71 | 45.16 | 33.33 | ---------+--------+--------+--------+--------+--------+ Total 30 27 31 31 30 149 20.13 18.12 20.81 20.81 20.13 100.00 Statistics for Table of sex by colh Statistic DF Value Prob ------------------------------------------------------ Chi-Square 4 8.5610 0.0731 Likelihood Ratio Chi-Square 4 8.6861 0.0694 Mantel-Haenszel Chi-Square 1 7.0135 0.0081 Phi Coefficient 0.2397 Contingency Coefficient 0.2331 Cramer's V 0.2397 Sample Size = 149 Examples with contingency tables - YOURNAME 9 2x5 table stored as 2 numerical samples 02:13 Thursday, September 8, 2005 Ms and Fs for males and females Frequency | MMMMM MMMMM 30 + MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM 25 + MMMMM MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM | MMMMM MMMMM MMMMM MMMMM MMMMM 20 + MMMMM MMMMM MMMMM MMMMM FFFFF | MMMMM MMMMM FFFFF MMMMM FFFFF | MMMMM MMMMM FFFFF MMMMM FFFFF | MMMMM MMMMM FFFFF FFFFF FFFFF | MMMMM MMMMM FFFFF FFFFF FFFFF 15 + MMMMM MMMMM FFFFF FFFFF FFFFF | MMMMM MMMMM FFFFF FFFFF FFFFF | MMMMM MMMMM FFFFF FFFFF FFFFF | MMMMM FFFFF FFFFF FFFFF FFFFF | MMMMM FFFFF FFFFF FFFFF FFFFF 10 + FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF 5 + FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF | FFFFF FFFFF FFFFF FFFFF FFFFF ------------------------------------------------------------------ 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 income Midpoint Symbol sex Symbol sex F F M M Examples with contingency tables - YOURNAME 10 Two-sample t-test for M versus F 02:13 Thursday, September 8, 2005 The TTEST Procedure Statistics Lower CL Upper CL Lower CL Variable sex N Mean Mean Mean Std Dev Std Dev income F 78 3.0154 3.3205 3.6256 1.1691 1.3531 income M 71 2.3662 2.7042 3.0423 1.2258 1.4282 income Diff (1-2) 0.1659 0.6163 1.0667 1.2471 1.3894 Statistics Upper CL Variable sex Std Dev Std Err Minimum Maximum income F 1.6066 0.1532 1 5 income M 1.7113 0.1695 1 5 income Diff (1-2) 1.5686 0.2279 T-Tests Variable Method Variances DF t Value Pr > |t| income Pooled Equal 147 2.70 0.0077 income Satterthwaite Unequal 144 2.70 0.0078 Equality of Variances Variable Method Num DF Den DF F Value Pr > F income Folded F 70 77 1.11 0.6420 Examples with contingency tables - YOURNAME 11 Two-sample Wilcoxon rank-sum test for M vs F 02:13 Thursday, September 8, 2005 The NPAR1WAY Procedure Wilcoxon Scores (Rank Sums) for Variable income Classified by Variable sex Sum of Expected Std Dev Mean sex N Scores Under H0 Under H0 Score ------------------------------------------------------------------- F 78 6528.0 5850.0 257.757976 83.692308 M 71 4647.0 5325.0 257.757976 65.450704 Average scores were used for ties. Wilcoxon Two-Sample Test Statistic 4647.0000 Normal Approximation Z -2.6284 One-Sided Pr < Z 0.0043 Two-Sided Pr > |Z| 0.0086 t Approximation One-Sided Pr < Z 0.0047 Two-Sided Pr > |Z| 0.0095 Z includes a continuity correction of 0.5. Kruskal-Wallis Test Chi-Square 6.9189 DF 1 Pr > Chi-Square 0.0085