options linesize=80 pagesize=37;	/* split plot MJ 24.2 */
data expt;
   infile 'split2.dat' firstobs=2;
   input moist fert tray yield;

proc glm;				/* split plot using glm */
   class tray fert moist;
   model yield = moist tray(moist) fert moist*fert / ss1;
   random tray(moist) / test;		/* tests using random statement */
   test h = moist e = tray(moist);	/* tests using test statement */
   means moist / lsd e = tray(moist);	/* means OK for balanced data */
   means fert / lsd;
   lsmeans moist*fert / pdiff stderr out=lsm;	/* save LS means dataset */

proc plot data=lsm;			/* interaction plots from glm */
   plot lsmean*fert=moist;
   plot lsmean*moist=fert;

data b; set expt;			/* polynomial contrasts using glm */
   wetlin = moist; wetquad = moist * moist;
   fertlin = fert; fertquad = fert * fert;
proc glm;
   class tray fert moist;
   model yield = wetlin wetquad moist tray(moist)
      fertlin fertquad fert moist*fert / ss1;
   test h = wetlin wetquad moist e = tray(moist);

proc mixed data=expt;			/* split plot using mixed */
   class tray fert moist;
   model yield = moist | fert;
   random tray(moist);
   lsmeans moist * fert;
   estimate 'fert linear' fert -3 -1 1 3 / divisor=20;	/* poly contrasts */
   estimate 'fert quadratic' fert -1 1 1 -1 / divisor=4;
   estimate 'moist linear' moist -3 -1 1 3 / divisor=20;
   estimate 'moist quadratic' moist -1 1 1 -1 / divisor=4;
   make 'lsmeans' out=lsm2;		/* save LS means dataset */

data plot; set lsm2;			/* pull out substrings with levels */
   fert = substr(level,12,1);
   moist = substr(level,14,2);
proc plot data=plot;			/* interaction plots from mixed */
   plot lsmean*fert=moist;
   plot lsmean*moist=fert;
