DM 'LOG;CLEAR;OUT;CLEAR;';
options nodate nonumber ls=80 ps=500;
data in;
do x1 = 1 to 0 by -1;
do x2 = 1 to 0 by -1;
do x3 = 1 to 0 by -1;
do x12 = 1 to 0 by -1;
if max(x1,x2)=0 then x12=0;
do x13 = 1 to 0 by -1;
if max(x1,x3)=0 then x13=0;
do x23 = 1 to 0 by -1;
if max(x2,x3)=0 then x23=0;
do x11 = 1 to 0 by -1;
if x1=0 then x11=0;
do x22 = 1 to 0 by -1;
if x2=0 then x22=0;
do x33 = 1 to 0 by -1;
if x3=0 then x33=0;
prm = 1 + sum(x1,x2,x3,x12,x13,x23,x11,x22,x33);
output;
end; end; end;
end; end; end;
end; end; end;
proc sort data=in; by descending prm x1-x3 x12 x13 x23 x11 x22 x33;
proc print data = in;
title '185 WH Reduced Models for k=3 Design Factors';
**************************************************;
data in; set in;
l = sum(of x1-x3);
q = sum(of x11,x22,x33);
h1=x1+x2; i1=0; j1=0;
h2=x1+x3; i2=0; j2=0;
h3=x2+x3; i3=0; j3=0;
if (h1 = 2) and (x12 = 1) then i1 = 1;
if (h2 = 2) and (x13 = 1) then i2 = 1;
if (h3 = 2) and (x23 = 1) then i3 = 1;
if (h1 = 1) and (x12 = 1) then j1 = 1;
if (h2 = 1) and (x13 = 1) then j2 = 1;
if (h3 = 1) and (x23 = 1) then j3 = 1;
c1 = sum(of i1-i3);
c2 = sum(of j1-j3);
m1=0; m2=0; m3=0;
if x1 = 1 then m1=1;
if x2 = 1 then m2=1;
if x3 = 1 then m3=1;
if x12= 1 then do; m1=1; m2=1; end;
if x13= 1 then do; m1=1; m3=1; end;
if x23= 1 then do; m2=1; m3=1; end;
dv = sum(of m1-m3);
resp = 1;
drop m1-m3;
proc sort data=in; by l c1 c2 q;
data in1; set in; by l c1 c2 q;
if first.q then output;
proc sort data=in; by l c1 c2 q;
proc means data=in noprint; by l c1 c2 q;
var resp;
output out=reduced n=freq;
data reduced; merge in1 reduced; by l c1 c2 q;
keep prm x1-x3 x12 x13 x23 x11 x22 x33 freq;
proc sort data=reduced; by descending prm x1-x3 x12 x13 x23 x11 x22 x33;
proc print data=reduced;
title '41 WH Reduced Models for Symmetric Designs for k=3 Design Factors';
run;