************************************************** * MACRO: CEFFECTS * * ANALYSIS OF TWO LEVEL FACTORIAL AND FRACTIONAL * * FACTORIAL DESIGNS WITH CENTER POINTS * *************************************************; %window ceffect group=name #1 @4 'ENTER THE NAME OF YOUR DATA SET' @55 dname1 16 attr=underline color=green required=yes #2 @4 'ENTER THE NAME OF THE DATA FILE TO STORE THE OUTPUT' @60 oname1 11 attr=underline color=green required=yes #3 @4 'ENTER THE NAME OF THE RESPONSE VARIABLE' @60 resp1 11 attr=underline color=green required=yes #4 @4 'ENTER THE NUMBER OF MAIN EFFECTS IN THE MODEL' @60 k1 11 attr=underline color=green required=yes group=level #6 @4 'DO YOU WANT TO SPECIFY THE CONFIDENCE LEVEL?' #7 @4 ' (Y/N) (DEFAULT=.95)' @55 conf1 8 attr=underline color=green required=yes group=enterl #8 @4 'ENTER YOUR CONFIDENCE LEVEL' @55 conf2 8 attr=underline color=green required=yes group=num1 #10 @4 'ENTER THE NAME OF THE FIRST MAIN EFFECT' @50 ef1 8 attr=underline color=green required=yes group=num2 #11 @4 'ENTER THE NAME OF THE SECOND MAIN EFFECT' @50 ef2 8 attr=underline color=green required=yes group=num3 #12 @4 'ENTER THE NAME OF THE THIRD MAIN EFFECT' @50 ef3 8 attr=underline color=green required=yes group=num4 #13 @4 'ENTER THE NAME OF THE FOURTH MAIN EFFECT' @50 ef4 8 attr=underline color=green required=yes group=num5 #14 @4 'ENTER THE NAME OF THE FIFTH MAIN EFFECT' @50 ef5 8 attr=underline color=green required=yes group=num6 #15 @4 'ENTER THE NAME OF THE SIXTH MAIN EFFECT' @50 ef6 8 attr=underline color=green required=yes group=num7 #16 @4 'ENTER THE NAME OF THE SEVENTH MAIN EFFECT' @50 ef7 8 attr=underline color=green required=yes group=message #18 @4 'PLEASE USE' @15 'SAS/INSIGHT' color=green @27 'TO MAKE THE NORMAL QUANTILE PLOT;' #19 @4 ' THE DATA IS PLACED IN' @36 'WORK.DRANK' color=green @46 ';' #20 @4 ' PLEASE USE' @20 'QUANTILE' color=green @29 'AS A VERTICAL AXIS VARIABLE,' #21 @4 ' USE' @15 'ESTIMATE' color=green @24 'AS A HORIZONTAL AXIS VARIABLE' #22 @4 ' AND USE' @18 'LABEL' color=green @24 'AS A LABEL VARIABLE. GOOD LUCK!' #24 @4 'HIT RETURN TO EXIT THIS MACRO' color=green attr=rev_video group=error #24 @10 'YOU HAVE ENTERED AN INVALID VALUE.' #25 @10 'THE MAXIMUM OF MAIN EFFECTS IS 7.' #26 @10 'PLEASE HIT RETURN, THEN TRY AGAIN.'; %macro ceffects; * THE NAMES OF DATA SET & OUTPUT FILE AND RESPONSE VARIABLE & NUMBER OF MAIN FACTORS ARE PROVIDED BY USERS; %choice: %display ceffect.name; %let dname=&dname1; %let dname1=; %let oname=&oname1; %let oname1=; %let resp=&resp1; %let resp1=; %let k=&k1; %let k1=; %if &k >= 8 %then %goto err; * SELECT THE CONFIDENCE LEVEL; %let gamma=0.95; %display ceffect.level; %let ctype=&conf1; %let conf1=; %if %upcase(&ctype)=Y %then %do; %display ceffect.enterl; %let gamma=&conf2; %let conf2=; %end; *LOOP FOR ENTERING NAMES OF MAIN FACTORS; %do i=1 %to &k; %display ceffect.num&i; %let eff&i=&&ef&i; %let ef&i=; %end; * GENERATE ALL INTERACTION VARIABLES; %macro startn; &resp %do i=1 %to &k; &&eff&i %end; %mend startn; data start; set &dname; keep %startn; run; data out1; set start; label &resp="&resp"; %do i=1 %to &k; label &&eff&i="&&eff&i"; %end; %do i1=1 %to &k-1; %if &k>=2 %then %do; %do i2=&i1+1 %to &k; I&i1&i2=&&eff&i1*&&eff&i2; label I&i1&i2="&&eff&i1*&&eff&i2"; %if (&k>=3) and (&i1<&k-1) and (&i2<&k) %then %do; %do i3=&i2+1 %to &k; I&i1&i2&i3=&&eff&i1*&&eff&i2*&&eff&i3; label I&i1&i2&i3="&&eff&i1*&&eff&i2*&&eff&i3"; %if (&k>=4) and (&i1<&k-2) and (&i2<&k-1) and (&i3<&k) %then %do; %do i4=&i3+1 %to &k; I&i1&i2&i3&i4=&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4; label I&i1&i2&i3&i4="&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4"; %if (&k>=5) and (&i1<&k-3) and (&i2<&k-2) and (&i3<&k-1) and (&i4<&k) %then %do; %do i5=&i4+1 %to &k; I&i1&i2&i3&i4&i5=&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4 *&&eff&i5; label I&i1&i2&i3&i4&i5= "&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4*&&eff&i5"; %if (&k>=6) and (&i1<&k-4) and (&i2<&k-3) and (&i3<&k-2) and (&i4<&k-1) and (&i5<&k) %then %do; %do i6=&i5+1 %to &k; I&i1&i2&i3&i4&i5&i6=&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4 *&&eff&i5*&&eff&i6; label I&i1&i2&i3&i4&i5&i6= "&&eff&i1*&&eff&i2*&&eff&i3*&&eff&i4*&&eff&i5*&&eff&i6"; %if &k=7 %then %do; I1234567=&eff1*&eff2*&eff3*&eff4*&eff5*&eff6*&eff7; label I1234567="&eff1*&eff2*&eff3*&eff4*&eff5*&eff6*&eff7"; %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; run; %macro names(namea,nameb); %do i=1 %to &k; &&&namea&i %end; %do i1=1 %to &k-1; %if &k>=2 %then %do; %do i2=&i1+1 %to &k; &nameb&i1&i2 %if (&k>=3) and (&i1<&k-1) and (&i2<&k) %then %do; %do i3=&i2+1 %to &k; &nameb&i1&i2&i3 %if (&k>=4) and (&i1<&k-2) and (&i2<&k-1) and (&i3<&k) %then %do; %do i4=&i3+1 %to &k; &nameb&i1&i2&i3&i4 %if (&k>=5) and (&i1<&k-3) and (&i2<&k-2) and (&i3<&k-1) and (&i4<&k) %then %do; %do i5=&i4+1 %to &k; &nameb&i1&i2&i3&i4&i5 %if (&k>=6) and (&i1<&k-4) and (&i2<&k-3) and (&i3<&k-2) and (&i4<&k-1) and (&i5<&k) %then %do; %do i6=&i5+1 %to &k; &nameb&i1&i2&i3&i4&i5&i6 %if (&k>=7) and (&i1<&k-5) and (&i2<&k-4) and (&i3<&k-3) and (&i4<&k-2) and (&i5<&k-1) and (&i6<&k) %then %do; &nameb.1234567 %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; %end; %mend names; * OUTPUTS ALL INTERACTION VARIABLES ALONG WITH THE RESPONSES AND FACTORS; data &oname; set out1; run; data contin; set out1; drop &resp; run; proc contents data=contin out=cont noprint; run; proc sort data=cont out=cont; by name; run; data cont; set cont; keep label; run; goptions reset=(title symbol axis); title "RESPONSE: &resp"; proc print data=&oname label noobs; var %names(eff,I); format %names(eff,I); run; title; * COMPUTE ESTIMATES FOR ALL MAIN FACTORS AND INTERACTIONS; proc reg data=out1 outest=out2 noprint; estimate: model &resp=%names(eff,I); run; proc transpose data=out2 out=out3 name=effect; var %names(eff,I); run; data out3; set out3; estimate=2*col1; keep effect estimate; * CREATE THE WORK.DRANK FOR NORMAL QUANTILE PLOT; goptions reset=(title symbol axis); proc rank data=out3 out=drank ties=mean normal=blom; var estimate; ranks blomrank; data drank; set drank; quantile=blomrank; keep effect quantile estimate; run; proc sort data=drank out=drank; by effect; run; data drank; merge drank cont; run; * COMPUTE MOE AND SMOE USING CLENTH PROCEDURE; %mesmoe: data sf32tmp; set out1; %do i=1 %to &k; if &&eff&i eq 0 then delete; %end; run; data sf32tmpc; set out1; %do i=1 %to &k; if &&eff&i ne 0 then delete; %end; run; proc univariate data=sf32tmp noprint; var &resp; output out=clenth1 std=sd n=n mean=mean; run; proc univariate data=sf32tmpc noprint; var &resp; output out=clenthc std=sd n=nc mean=meanc; run; goptions reset=(title symbol axis); data clenth2; merge clenth1 clenthc; tmp=sqrt(1/n+1/nc); se0=sd*sqrt(1/n+1/nc); curv=mean-meanc; securv=se0*tinv((1+&gamma)/2,nc-1); moe=2*sd*tinv((1+&gamma)/2,nc-1)/sqrt(2**(&k)); m=2**(&k)-1; smoe=2*sd*tinv((1+&gamma**(1/m))/2,nc-1)/sqrt(2**(&k)); csize=abs(curv); signif='a '; if csize <= securv then do; signif='no'; end; call symput('SIGS',left(signif)); run; data dcurv; set clenth2; estimate=securv; cu='curvature'; output; estimate=-securv; cu='curvature'; output; estimate=0; cu='curvature'; output; estimat1=curv; cu='curvature'; output; symbol1 color=blue i=hilot; symbol2 color=red value=triangle; axis1 label=none minor = none; proc gplot data=dcurv; title color=green height=4 pct "THE CURVATURE PLOT (LEVEL = &gamma)"; plot estimate*cu estimat1*cu / haxis=axis1 overlay; title2 box=2 color=red height=3 pct "CONCLUSION: THERE IS %upcase(&SIGS) SIGNIFCANT SURFACE CURVATURE."; run; quit; goptions reset=(title symbol axis); data out4; set out3; if _n_=1 then set clenth2; mmoe=-moe; msmoe=-smoe; keep effect estimate moe mmoe smoe msmoe; run; * OUTPUTS ESTIMATES, MOE AND MSE; proc sort data=out4 out=out4; by effect; run; data out4; merge out4 cont; run; title "RESPONSE: &resp"; proc print data=out4 noobs; *var effect label estimate moe mmoe smoe msmoe; *format effect label estimate moe mmoe smoe msmoe; var effect label estimate moe smoe; format effect label estimate moe smoe; run; title; * DISPLAY THE PLOT SHOWING THE EFFECTS AND THE VALUES OF MOE AND MSE; symbol1 color=red i=needle; symbol2 color=blue i=j line=2; symbol3 color=blue i=j line=2; symbol4 color=brown i=j line=3; symbol5 color=brown i=j line=3; %if &k=7 %then %goto next; axis1 label=('EFFECT'); proc gplot data=out4; title1 color=green height=4 pct "THE MOE AND SMOE PLOT (LEVEL = &gamma)"; title2 color=green "RESPONSE: &resp"; plot (estimate moe mmoe smoe msmoe)*effect/frame overlay haxis=axis1; run; quit; %goto finish; %next: data out41; set out4; id=_n_; if id <= 64; data out42; set out4; id=_n_; if id > 64; axis1 label=('EFFECT'); proc gplot data=out41; title1 color=green height=4 pct "THE FIRST HALF OF MOE AND SMOE PLOT (LEVEL = &gamma)"; title2 color=green "RESPONSE: &resp"; plot (estimate moe mmoe smoe msmoe)*effect/frame overlay haxis=axis1; run; quit; axis1 label=('EFFECT'); proc gplot data=out42; title1 color=green height=4 pct "THE SECOND HALF OF MOE AND SMOE PLOT (LEVEL = &gamma)"; title2 color=green "RESPONSE: &resp"; plot (estimate moe mmoe smoe msmoe)*effect/frame overlay haxis=axis1; run; quit; %goto finish; %err: %display ceffect.error; %goto choice; %finish: goptions reset=(symbol axis title); %display ceffect.message; title; %mend ceffects; %ceffects;