title 'Three factor design with repeated measures'; * SOURCE: WINER, 1971, P.564 & SAS USERS' GUIDE:STATISTICS ; data a; input subj a b c1-c4; label a = 'anxiety' b = 'tension' subj = 'subject' c1 = 'errors trial 1' c2 = 'errors trial 2' c3 = 'errors trial 3' c4 = 'errors trial 4'; datalines; 1 1 1 18 14 12 6 2 1 1 19 12 8 4 3 1 1 14 10 6 2 4 1 2 16 12 10 4 5 1 2 12 8 6 2 6 1 2 18 10 5 1 7 2 1 16 10 8 4 8 2 1 18 8 4 1 9 2 1 16 12 6 2 10 2 2 19 16 10 8 11 2 2 16 14 10 9 12 2 2 16 12 8 8 ; proc print; title2 'Original data -- Repeated format'; data b; *-- ravel to 4 obs per subject; set a; drop c1-c4; array r(c) c1-c4; do c = 1 to 4; response = r ; output; end; proc print data=b; title2 'Ravelled data -- Univariate format'; run; %splot(data=b, class=A B, var=RESPONSE); title2 'Between-group effects'; %splot(data=b, class=C, var=RESPONSE); title2 'Within-group effects'; proc glm data=b; class a b subj c; model response = a b a*b subj(a b) c a*c b*c a*b*c; random subj(a b); test h = a b a*b e = subj(a b); title2 'Balanced design, mixed model analysis'; run;