/* Two Sample Test for Unequal Binomial Proportions */

filename t01 url 'http://hedwig.mgh.harvard.edu/biostatistics/sites/default/files/public/education/tmp_sample_data.csv';

proc import file=t01 out=t01 dbms=csv replace;
run;

proc freq data=t01;
table diabetes*gender/ chisq;
run;

/********************************** ANNOTATED RESULTS **********************************/

                               The FREQ Procedure

                          Table of diabetes by gender

                      diabetes     gender

                      Frequency|
                      Percent  |
                      Row Pct  |
                      Col Pct  |       0|       1|  Total
                      ---------+--------+--------+
                             0 |     13 |     30 |     43
                               |  21.67 |  50.00 |  71.67
                               |  30.23 |  69.77 |
                               |  81.25 |  68.18 |
                      ---------+--------+--------+
                             1 |      3 |     14 |     17
                               |   5.00 |  23.33 |  28.33
                               |  17.65 |  82.35 |
                               |  18.75 |  31.82 |a
                      ---------+--------+--------+
                      Total          16       44       60
                                  26.67    73.33   100.00


                   Statistics for Table of diabetes by gender

             Statistic                     DF       Value      Prob
             ------------------------------------------------------
             Chi-Square                     1      0.9868    0.3205b
             Likelihood Ratio Chi-Square    1      1.0432    0.3071
             Continuity Adj. Chi-Square     1      0.4482    0.5032
             Mantel-Haenszel Chi-Square     1      0.9704    0.3246
             Phi Coefficient                       0.1282
             Contingency Coefficient               0.1272
             Cramer's V                            0.1282

              WARNING: 25% of the cells have expected counts less
                       than 5. Chi-Square may not be a valid test.


                              Fisher's Exact Test
                       ----------------------------------
                       Cell (1,1) Frequency (F)        13
                       Left-sided Pr <= F          0.9098
                       Right-sided Pr >= F         0.2565

                       Table Probability (P)       0.1662
                       Two-sided Pr <= P           0.5181c

                                Sample Size = 60
                       
        
a This row shows 18.75% (3/16) of gender 0 and 31.82% (14/44) of gender 1 are diabetic
b Chi-square test p-value indicating proportion of diabetics not significantly different in gender 0 and gender 1
c Fisher's Exact Test test p-value indicating proportion of diabetics not significantly different in gender 0 and gender 1