/* One Sample Test for Binomial Proportion */

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/ binomial(level='1' p=0.50);
exact binomial;
run;


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

                              The FREQ Procedure

                                              Cumulative    Cumulative
         diabetes    Frequency     Percent     Frequency      Percent
         -------------------------------------------------------------
                0          43       71.67            43        71.67
                1          17       28.33            60       100.00


                     Binomial Proportion for diabetes = 1
                     -------------------------------------
                     Proportion (P)                 0.2833a
                     ASE                            0.0582
                     95% Lower Conf Limit           0.1693
                     95% Upper Conf Limit           0.3974b

                     Exact Conf Limits
                     95% Lower Conf Limit           0.1745
                     95% Upper Conf Limit           0.4144

                         Test of H0: Proportion = 0.5

                     ASE under H0                   0.0645
                     Z                             -3.3566
                     One-sided Pr <  Z              0.0004
                     Two-sided Pr > |Z|             0.0008c

                     Exact Test
                     One-sided Pr <=  P          5.329E-04
                     Two-sided = 2 * One-sided      0.0011

                                Sample Size = 60
            
        
a Proportion of subjects having diabetes
b 95% confidence interval for proportion
c P-value indicating proportion significantly different from 0.5