1 The SAS System 10:26 Thursday, February 19, 1998 NOTE: Copyright(c) 1989 by SAS Institute Inc., Cary, NC USA. NOTE: SAS (r) Proprietary Software Release 6.07 TS203 Licensed to UNIVERSITY OF TORONTO, Site 0008987003. NOTE: AUTOEXEC processing beginning; file is /local/lib/sas/autoexec.sas. NOTE: SAS initialization used: real time 0.138 seconds cpu time 0.143 seconds NOTE: AUTOEXEC processing completed. 1 /************* castle98a.sas ********************* 2 Two-way ANOVA SAS example with dummy var coding: 3 See Section 19.4; data on P. 818 4 ***************************************************/ 5 6 options linesize = 79; 7 8 proc format; 8 /* value labels used in data step below */ 9 value htfmt 1 = 'Bottom' 2 = 'Middle' 3 = 'Top'; NOTE: Format HTFMT has been output. 10 value widfmt 1 = 'Regular' 2 = 'Wide'; NOTE: Format WIDFMT has been output. 11 NOTE: PROCEDURE FORMAT used: real time 0.034 seconds cpu time 0.014 seconds 12 data bake; 13 infile 'castle.dat'; 14 input height width sales; 15 label height = 'Display Height' 16 width = 'Display Width' 17 sales = 'Sales in cases'; 18 format height htfmt.; 19 format width widfmt.; /* Asssociate variables with print formats */ 20 /* Effect dummy variable coding */ 21 if width = 1 then w1 = 1; else w1 = -1; 22 if height = 1 then h1 = 1; 23 else if height = 3 then h1 = -1; 24 else h1 = 0; 25 if height = 2 then h2 = 1; 26 else if height = 3 then h2 = -1; 27 else h2 = 0; 28 h1w1 = h1*w1 ; h2w1 = h2*w1; /* Interactions */ 29 /* Cell means coding: indicators are named after their parameters. */ 30 if height = 1 and width = 1 then mu11 = 1 ; else mu11 = 0; 2 The SAS System 10:26 Thursday, February 19, 1998 31 if height = 1 and width = 2 then mu12 = 1 ; else mu12 = 0; 32 if height = 2 and width = 1 then mu21 = 1 ; else mu21 = 0; 33 if height = 2 and width = 2 then mu22 = 1 ; else mu22 = 0; 34 if height = 3 and width = 1 then mu31 = 1 ; else mu31 = 0; 35 if height = 3 and width = 2 then mu32 = 1 ; else mu32 = 0; 36 /* Make combination variable */ 37 hwcombo = 10*height + width; 38 NOTE: The infile 'castle.dat' is: File Name=/student/jbrunner/sta402s98/castle.dat, Owner Name=jbrunner,Group Name=research, Access Permission=rw-------, File Size (bytes)=133 NOTE: 13 records were read from the infile 'castle.dat'. The minimum record length was 0. The maximum record length was 10. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set WORK.BAKE has 12 observations and 15 variables. NOTE: DATA statement used: real time 0.234 seconds cpu time 0.033 seconds 39 proc freq; 40 tables height * width / nopercent norow nocol; 41 tables hwcombo * (height width) / nopercent norow nocol; 42 NOTE: The PROCEDURE FREQ printed pages 1-2. NOTE: PROCEDURE FREQ used: real time 0.024 seconds cpu time 0.019 seconds 43 proc glm; /* glm does the dummy vars for us */ 44 class height width; 45 model sales = height width height*width; 46 means height width height*width; 47 means height / alpha=.05 tukey bon scheffe cldiff; 48 /* Why didn't I bother to do it for shelf width? */ 49 NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement. NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement. NOTE: The PROCEDURE GLM printed pages 3-8. NOTE: PROCEDURE GLM used: real time 0.060 seconds cpu time 0.059 seconds 50 proc reg; /* Now do it with dummy var regression using effect coding */ 3 The SAS System 10:26 Thursday, February 19, 1998 51 model sales = h1 h2 w1 h1w1 h2w1; 52 height: test h1=h2=0; 53 width: test w1 = 0; 54 h_by_w: test h1w1 = h2w1 = 0; 55 NOTE: 12 observations read. 12 observations used in computations. NOTE: The PROCEDURE REG printed pages 9-12. NOTE: PROCEDURE REG used: real time 0.176 seconds cpu time 0.016 seconds 56 proc reg; /* Now with cell means coding */ 57 model sales = mu11 -- mu32 / noint ; 58 height: test mu11+mu12=mu21+mu22=mu31+mu32; 59 width: test mu11+mu21+mu31=mu12+mu22+mu32; 60 h_by_w: test mu11-mu12 = mu21-mu22 = mu31-mu32; 61 NOTE: 12 observations read. 12 observations used in computations. NOTE: The PROCEDURE REG printed pages 13-16. NOTE: PROCEDURE REG used: real time 0.245 seconds cpu time 0.015 seconds 62 proc glm; /* Combination variables are good for comparing cell means */ 63 class hwcombo; 64 model sales=hwcombo; 65 means hwcombo / tukey; /* Could have used cldiff option */ 66 NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement. NOTE: The PROCEDURE GLM printed pages 17-19. NOTE: PROCEDURE GLM used: real time 0.039 seconds cpu time 0.039 seconds NOTE: The SAS System used: real time 0.972 seconds cpu time 0.360 seconds NOTE: SAS Institute Inc., SAS Circle, PO Box 8000, Cary, NC 27512-8000