/* Example of Repeated Measures Analysis MJ 26.1*/
options linesize=80 pagesize=50;
data repeat;
   infile 'repeat.dat' firstobs=2;
   input t1 t2 t3 t4 trt $;

proc glm;			/* repeated measures using proc glm */
   class trt;
   model t1 t2 t3 t4 = trt;
   repeated time 4 (1 2 3 4) polynomial / summary;
   lsmeans trt / out=lsm;
data times; set lsm;
   period = substr(_NAME_,2,1);
proc plot;
   plot lsmean*period=trt;

data mixed; set repeat;
   person = _N_;
   y = t1; period = 1; output;
   y = t2; period = 2; output;
   y = t3; period = 3; output;
   y = t4; period = 4; output;
   drop t1--t4;

/* SOMETHING IS NOT QUITE RIGHT WITH THIS -- WATCH THIS SPACE */
proc mixed;			/* repeated measures using proc mixed */
   class trt period person;
   model y = trt|period;
   repeated / type=cs sub=person(trt);
   lsmeans trt*period;

proc mixed;			/* split plot using mixed */
   class trt period person;
   model y = trt|period;
   random person(trt);
   lsmeans trt*period;

proc glm;
   class trt period person;
   model y = trt person(trt) period period*trt;
   test h=trt e=person(trt);
   random person(trt) / test;
