/* this is a comment */ options ls=79 ps=50 nocenter; /* sas page layout options */ data forcow; /* read data */ infile 'forcow.dat' firstobs=2; /* data begins on line 2 */ input hc $ trt code id dmi; /* input data (hc has characters) */ /* hc = H (heifer) or C (cow) */ /* trt = 1-5 for amount of alfalfa in diet */ /* code = 1-5 for hc=H, 6-0 for hc=C */ /* id = unique identification number of animal */ /* dmi = dry matter intake per day (pounds) */ if hc = 'H'; /* I do heifer, you do cow */ proc sort; by trt; /* sorting can be very handy */ proc univariate plot normal; /* histogram type summaries */ var dmi; proc univariate plot normal; by trt; var dmi; proc glm; /* one-factor anova */ class trt; /* trt is factor of interest */ model dmi = trt / ss1; /* model statement */ means trt / lsd lines; /* ordinary means, multiple comparisons */ lsmeans trt / pdiff stderr; /* least squares means, pairwise tests */ contrast 'linear' trt -2 -1 0 1 2; /* linear contrast */ contrast 'quad' trt 2 -1 -2 -1 2; /* quadratic contrast */ contrast 'cubic' trt -1 2 0 -2 1; /* cubic contrast */ contrast 'quart' trt 1 -4 6 -4 1; /* quartic contrast */ estimate 'slope' trt -2 -1 0 1 2 / divisor=10; /* estimates */ estimate 'quad' trt 2 -1 -2 -1 2 / divisor=14; estimate 'cubic' trt -1 2 0 -2 1 / divisor=10; estimate 'quart' trt 1 -4 6 -4 1 / divisor=70; output out=fit p=pdmi r=rdmi; /* save pred and resid for plot */ data jitter; set fit; /* 4% jitter of means for plot */ jitdmi = pdmi + .2*ranuni(0) - .1; /* .2 = 4% of range of response */ proc plot; /* SHOW REGULAR OR JITTERED (NOT BOTH) */ plot dmi*jitdmi=trt; /* jittered mean against response */ plot rdmi*jitdmi=trt; /* jittered residual plot */ plot rdmi*pdmi=trt; /* regular residual plot */ run;