/* One-Way ANOVA and Confidence Intervals for Mean BMI by Race */

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

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

ods listing select tests3 lsmeans diffs;

proc mixed data=t01;
class race;
model bmi=race /s;
lsmeans race /cl diffs adjust=bon;
run;

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

                                The SAS System

                              The Mixed Procedure

                         Type 3 Tests of Fixed Effects

                               Num     Den
                 Effect         DF      DF    F Value    Pr > F

                 race            2      57       0.88    0.4189a


                              Least Squares Means

                              Standard
Effect    race    Estimate       Error      DF    t Value    Pr > |t|     Alpha

race      1        26.0742      0.6767      57      38.53      <.0001      0.05
race      2        26.6053      0.8644      57      30.78      <.0001      0.05
race      3        24.6600      1.1914      57      20.70      <.0001      0.05

                              Least Squares Means

                     Effect    race       Lower       Upper

                     race      1        24.7191     27.4292
                     race      2        24.8744     28.3361
                     race      3        22.2742     27.0458


                       Differences of Least Squares Means

                                Standard
 Effect  race  _race  Estimate     Error    DF  t Value  Pr > |t|  Adjustment

 race    1     2       -0.5311    1.0977    57    -0.48    0.6304  Bonferroni
 race    1     3        1.4142    1.3702    57     1.03    0.3064  Bonferroni
 race    2     3        1.9453    1.4720    57     1.32    0.1916  Bonferroni

                      Differences of Least Squares Means

                                                               Adj       Adj
  Effect  race  _race   Adj P   Alpha     Lower     Upper      Lower     Upper

  race    1     2      1.0000    0.05   -2.7293    1.6671b   -3.2389    2.1767
  race    1     3      0.9191    0.05   -1.3296    4.1580     -1.9657    4.7940
  race    2     3      0.5748    0.05   -1.0023    4.8928     -1.6856    5.5761
            
        
a P-value indicating no significant effect of race on BMI
b 95% confidence interval for race 1 minus race 2 difference