1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;5556 /************* classicalmixed.sas *********************57 Three levels of factor A, four levels of B58 Both fixed59 Both random60 A fixed, B random61 B nested within A62 ***************************************************/6364 data mixedup;65 infile '/folders/myfolders/mixedup.data.txt';66 input ID Y A B;67NOTE: The infile '/folders/myfolders/mixedup.data.txt' is:Filename=/folders/myfolders/mixedup.data.txt,Owner Name=root,Group Name=vboxsf,Access Permission=-rwxrwx---,Last Modified=05Mar2016:15:49:20,File Size (bytes)=972NOTE: 36 records were read from the infile '/folders/myfolders/mixedup.data.txt'.The minimum record length was 25.The maximum record length was 25.NOTE: The data set WORK.MIXEDUP has 36 observations and 4 variables.NOTE: DATA statement used (Total process time):real time 0.00 secondscpu time 0.01 seconds68 proc glm plots=none;69 title 'Default proc glm: Both Fixed';70 class A B ;71 model y = a | b;72 means a*b;73NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement.NOTE: PROCEDURE GLM used (Total process time):real time 0.10 secondscpu time 0.10 seconds74 proc glm plots=none;75 title 'Both Random with proc glm';76 class A B ;77 model y = a | b;78 random a b a*b / test ;79 /* Have to specify interaction random too,80 and explicitly ask for tests */81NOTE: TYPE I EMS not available without the E1 option.NOTE: PROCEDURE GLM used (Total process time):real time 0.09 secondscpu time 0.09 seconds82 proc glm plots=none;83 title 'A Fixed, B Random';84 class A B ;85 model y = a | b;86 random b a*b / test;87NOTE: TYPE I EMS not available without the E1 option.NOTE: PROCEDURE GLM used (Total process time):real time 0.09 secondscpu time 0.08 seconds88 proc glm plots=none;89 title 'A fixed, B random and nested within A';90 class A B ;91 model y = a b(a);92 random b(a) / test;93NOTE: TYPE I EMS not available without the E1 option.NOTE: PROCEDURE GLM used (Total process time):real time 0.09 secondscpu time 0.09 seconds94 proc mixed cl; /*Confidence Limits for variances (There are no tests) */95 title 'A fixed, B random and nested within A';96 title2 'Using proc mixed';97 title3 'Compare F for A = 7.32, F for B(A) = 3.11, p = 0.0126';98 class A B ;99 model y = a ;100 random b(a);101NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.08 secondscpu time 0.07 seconds102 proc glm plots=none;103 title 'Both random, B nested within A';104 class A B ;105 model y = a b(a);106 random a b(a) / test;107NOTE: TYPE I EMS not available without the E1 option.NOTE: PROCEDURE GLM used (Total process time):real time 0.09 secondscpu time 0.08 seconds108 proc sort; by A B; /* Data must be sorted in order of nesting*/NOTE: There were 36 observations read from the data set WORK.MIXEDUP.NOTE: The data set WORK.MIXEDUP has 36 observations and 4 variables.NOTE: PROCEDURE SORT used (Total process time):real time 0.00 secondscpu time 0.00 seconds109 proc nested;110 title 'Nested random effects with proc nested';111 title2 'Compare F for A = 7.32, F for B(A) = 3.11';112 class A B;113 var Y;114NOTE: PROCEDURE NESTED used (Total process time):real time 0.04 secondscpu time 0.04 seconds115 proc mixed cl;116 title 'Pure nested with proc mixed';117 class A B ;118 model y = ;119 random a b(a);120121 /****** What happens when the data are unbalanced? ******/122NOTE: Convergence criteria met.NOTE: PROCEDURE MIXED used (Total process time):real time 0.06 secondscpu time 0.06 seconds123 proc glm plots=none;124 title 'UNBALANCED: Both random, B nested within A';125 title2 'Using proc glm';126 title3 'Compare F for A = 7.32, F for B(A) = 3.11';127 where id ne 1; /* Throw out one case */128 class A B ;129 model y = a b(a);130 random a b(a) / test;131NOTE: TYPE I EMS not available without the E1 option.NOTE: PROCEDURE GLM used (Total process time):real time 0.10 secondscpu time 0.09 seconds132 proc sort; by A B; /* Data must be sorted in order of nesting*/NOTE: Input data set is already sorted, no sorting done.NOTE: PROCEDURE SORT used (Total process time):real time 0.00 secondscpu time 0.00 seconds133 proc nested;134 title 'UNBALANCED: Nested random effects with proc nested';135 title2 'Proc glm gave F for A = 7.38, F for B(A) = 2.77';136 where id ne 1; /* Throw out one case */137 class A B;138 var Y;139WARNING: The design is not balanced--F tests cannot be computed.NOTE: PROCEDURE NESTED used (Total process time):real time 0.04 secondscpu time 0.03 seconds140 proc mixed cl;141 title 'UNBALANCED: Pure nested with proc mixed';142 title2 'Proc nested estimated Var[A]=14.39, Var[B(A)]=6.25';143 where id ne 1; /* Throw out one case */144 class A B ;145 model y = ;146 random a b(a);147148149150151152 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;164