* This is file EATING.SAS ; title 'One-way repeated measures -- eating and metobolism data'; * read in data set ; DATA; infile eating; input R A1 A2 A3 A4 A5 Ee Es Group Subject; LABEL R='metabolic rate after eating' Ee='dummy var. = 1 if bypass stomach' Es='dummy var. = 1 if direct to stomach' A1='dummy variable =1 if subject 1' A2='dummy variable =1 if subject 2' A3='dummy variable =1 if subject 3' A4='dummy variable =1 if subject 4' A5='dummy variable =1 if subject 5' Group='Treatment group' Subject='Subject number'; * Do analysis of variance using regression with dummy variables ; proc REG; model R=A1-A5 Ee Es/ SS1; * Traditional ANOVA (with repeated measures) using ; * GLM with random subcommand to specify model: ; * This will be the way we handle missing data. ; proc GLM; class Group Subject; model R=Group Subject/solution; random Subject; lsmeans Group/stderr pdiff; * Use SORT and TRANSPOSE to convert data set ; * into form where each row contains the repeated ; * observations from each subject, which is the ; * easiest way to get SAS to do traditional ANOVA ; DATA; set; keep R Subject; proc SORT; by Subject; proc TRANSPOSE; Var R; by Subject; DATA; set; keep COL1-COL3; rename COL1=Enorm COL2=Ee COL3=Es; * Do traditional analysis of variance on transposed ; * data set. Notice that the model statement contains ; * no "class" variables, because there is only one ; * factor that, because it has repeated measures, is ; * represented only by the 3 "dependent" variables, ; * Enorm, Ee, Es that identify the treatment groups ; proc ANOVA; model Enorm Ee Es=; repeated TREATMT/nom; * Get data file with missing data for GLM anova ; DATA; infile eatmis1; input R A1 A2 A3 A4 A5 Ee Es Group Subject; LABEL R='metabolic rate after eating' Group='Treatment group' Subject='Subject number'; * Traditional ANOVA (with repeated measures) using ; * GLM with random subcommand to specify model ; proc GLM; class Group Subject; model R=Group Subject/solution; random Subject; lsmeans Group/stderr pdiff;