**** This macro uses %window to get all the input necessary to run the MCPower macro and then runs the MCPower macro; **** modify the %include statement to point to the MCPOWER1.SAS file; %include "C:\MCPower\univariatesinglepredictor\univar macro 4.sas"; %window intro IROW=2 ICOLUMN=2 ROWS=50 COLUMNS=70 #3 @3 "The MCPower macro works by simulating data sets under your" #4 @3 "requested alternative hypotheses and with variable numbers of" #5 @3 "subjects. For each alternative, the macro generates multiple data" #6 @3 "sets and determines if the null hypothesis would have been rejected" #7 @3 "by the desired model in each case. The result is estimated power," #8 @3 "where the accuracy of the estimate is a function of the number of" #9 @3 "data sets. More data sets improve the estimation, but increase the" #10 @3 "time needed to generate the estimates." #12 @3 "The following screens offer access to most of the options" #13 @3 "available in the macro." #15 @3 "Please press [ENTER] to continue." ; %window distributions IROW=2 ICOLUMN=2 ROWS=50 COLUMNS=70 GROUP=outcome #3 @3 "In order to calculate the required power and/or sample size, you" #4 @3 "must provide some information." #7 @7 "Please choose the distribution of the outcome variable (y) by" #8 @7 "putting any character in the blank next to the distribution," #9 @7 "then pressing [ENTER]:" #11 @11 out1 1 ATTR=UNDERLINE COLOR=Blue @13 "Normal (Ordinary least squares regression)" COLOR=Blue #12 @11 out2 1 ATTR=UNDERLINE COLOR=Blue @13 "Poisson (Poisson or count regression)" COLOR=Blue #13 @11 out3 1 ATTR=UNDERLINE COLOR=Blue @13 "Bernoulli (Logistic regression)" COLOR=Blue GROUP=ynorm #16 @11 "You have chosen the Normal Distribution. Using a" #17 @11 "standard deviation of 1 will allow you to express the" #18 @11 "results in standard deviation units. Please enter" #19 @11 "the standard deviation: " scaley 5 ATTR=underline COLOR=Blue GROUP=ypois #16 @11 "You have chosen the Poisson Distribution. Please enter" #17 @11 "the mean with the outcome when the predictor is 0: " intercept 5 ATTR=underline COLOR=Blue GROUP=ybern #16 @11 "You have chosen the Bernoulli Distribution. Please enter" #17 @11 "the proportion with the outcome when the predictor is 0: " intercept 5 ATTR=underline COLOR=Blue GROUP=predictor #25 @7 "Please choose the distribution of the predictor variable (x):" #27 @11 pred1 1 ATTR=UNDERLINE COLOR=Blue @13 "Normal (you will need to enter the mean and standard" COLOR=Blue #28 @13 "deviation)" COLOR=Blue #29 @11 pred2 1 ATTR=UNDERLINE COLOR=Blue @13 "Poisson (you will need to enter the mean)" COLOR=Blue #30 @11 pred3 1 ATTR=UNDERLINE COLOR=Blue @13 "Bernoulli (you will need to enter the probability of" COLOR=Blue #31 @13 "success)" COLOR=Blue #32 @11 pred4 1 ATTR=UNDERLINE COLOR=Blue @13 "Binomial (you will need to enter the probability of" COLOR=Blue #33 @13 "success and the number of Bernoulli trials)" COLOR=Blue #34 @11 pred5 1 ATTR=UNDERLINE COLOR=Blue @13 "Beta (you will need to enter 2 shape parameters)" COLOR=Blue #35 @11 pred6 1 ATTR=UNDERLINE COLOR=Blue @13 "Exponential (you will need to enter the mean)" COLOR=Blue #36 @11 pred7 1 ATTR=UNDERLINE COLOR=Blue @13 "Uniform" COLOR=Blue #37 @11 pred8 1 ATTR=UNDERLINE COLOR=Blue @13 "T (you will need to enter the degrees of freedom)" COLOR=Blue GROUP=xnorm #40 @11 "You have chosen the Normal Distribution." #41 @11 "Please enter the mean: " xloc 5 ATTR=underline COLOR=Blue #42 @11 "Please enter the standard deviation: " xscale 5 ATTR=underline COLOR=Blue GROUP=xpois #40 @11 "You have chosen the Poisson Distribution." #41 @11 "Please enter the mean: " xloc 5 ATTR=underline COLOR=Blue GROUP=xbern #40 @11 "You have chosen the Bernoulli Distribution." #41 @11 "Please enter p, the probability of success: " xloc 5 ATTR=underline COLOR=Blue GROUP=xbin #40 @11 "You have chosen the Binomial Distribution." #41 @11 "Please enter p, the probability of success: " xloc 5 ATTR=underline COLOR=Blue GROUP=xbeta #40 @11 "You have chosen the Beta Distribution." #41 @11 "Please enter the first parameter: " xloc 5 ATTR=underline COLOR=Blue #42 @11 "Please enter the second parameter: " xscale 5 ATTR=underline COLOR=Blue GROUP=xexp #40 @11 "You have chosen the Exponential Distribution." #41 @11 "Please enter the mean: " xloc 5 ATTR=underline COLOR=Blue #34 @20 "Please enter the mean: " xloc 5 ATTR=underline COLOR=Blue GROUP=xuni #40 @11 "You have chosen the Uniform Distribution." #41 @11 "Please press [ENTER] to continue." GROUP=xt #40 @11 "You have chosen the T Distribution." #41 @11 "Please enter the degrees of freedom: " xloc 5 ATTR=underline COLOR=Blue GROUP=distErr #22 @20 "There is an error in your choice of distribution." COLOR=Red #23 @20 "Press [ENTER] to choose the distribution." COLOR=Red ; %window misc IROW=2 ICOLUMN=2 ROWS=50 COLUMNS=70 GROUP=hypothesesnorm #3 @3 "Now we need some information about the hypotheses to be tested, sample" #4 @3 "size, etc.." #7 @3 "Hypotheses" #9 @7 "You have indicated that you will be doing OLS regression. The " #10 @7 "null hypothesis for OLS regression is typically a slope of 0." #11 @7 "Please enter the slope under the null hypothesis for your" #12 @7 "study: " nullhyp 8 ATTR=underline COLOR=Blue #14 @7 "You may enter up to 3 alternative hypotheses. Note that there" #15 @7 "will be one curve for each alternative on the graphical output." #16 @7 "If you do not want 3 alternatives, please leave the extra " #17 @7 "blanks empty." #19 @7 "Please enter the slopes desired under the alternative" #20 @7 "hypothesis:" #22 @11 "First slope: " alt1 8 ATTR=underline COLOR=Blue #23 @11 "Second slope: " alt2 8 ATTR=underline COLOR=Blue #24 @11 "Third slope: " alt3 8 ATTR=underline COLOR=Blue GROUP=hypothesespois #3 @3 "Now we need some information about the hypotheses to be tested, sample" #4 @3 "size, etc.." #7 @3 "Hypotheses" #9 @7 "You have indicated that you will be doing Poisson regression." #10 @7 "The null hypothesis for Poisson regression is typically a" #11 @7 "relative rate of 1. Please enter the relative rate under" #12 @7 "the null hypothesis for your study: " nullhyp 8 ATTR=underline COLOR=Blue #14 @7 "You may enter up to 3 alternative hypotheses. Note that there" #15 @7 "will be one curve for each alternative on the graphical output." #16 @7 "If you do not want 3 alternatives, please leave the extra " #17 @7 "blanks empty." #19 @7 "Please enter the relative rates desired under the alternative" #20 @7 "hypothesis:" #22 @11 "First relative rate: " alt1 8 ATTR=underline COLOR=Blue #23 @11 "Second relative rate: " alt2 8 ATTR=underline COLOR=Blue #24 @11 "Third relative rate: " alt3 8 ATTR=underline COLOR=Blue GROUP=hypothesesbern #3 @3 "Now we need some information about the hypotheses to be tested, sample" #4 @3 "size, etc.." #7 @3 "Hypotheses" #9 @7 "You have indicated that you will be doing logistic regression." #10 @7 "The null hypothesis for logistic regression is typically an" #11 @7 "odds ratio of 1. Please enter the odds ratio under the" #12 @7 "null hypothesis for your study: " nullhyp 8 ATTR=underline COLOR=Blue #14 @7 "You may enter up to 3 alternative hypotheses. Note that there" #15 @7 "will be one curve for each alternative on the graphical output." #16 @7 "If you do not want 3 alternatives, please leave the extra " #17 @7 "blanks empty." #19 @7 "Please enter the odds ratios desired under the alternative" #20 @7 "hypothesis:" #22 @11 "First odds ratio: " alt1 8 ATTR=underline COLOR=Blue #23 @11 "Second odds ratio: " alt2 8 ATTR=underline COLOR=Blue #24 @11 "Third odds ratio: " alt3 8 ATTR=underline COLOR=Blue GROUP=samplesize #27 @3 "Sample Size" #29 @7 "You may enter up to 10 sample sizes. If you do not want 10 sample" #30 @7 "sizes, please leave the extra blanks empty." #31 @7 "Sample size 1: " n1 8 ATTR=underline COLOR=Blue #31 @40 "Sample size 2: " n2 8 ATTR=underline COLOR=Blue #32 @7 "Sample size 3: " n3 8 ATTR=underline COLOR=Blue #32 @40 "Sample size 4: " n4 8 ATTR=underline COLOR=Blue #33 @7 "Sample size 5: " n5 8 ATTR=underline COLOR=Blue #33 @40 "Sample size 6: " n6 8 ATTR=underline COLOR=Blue #34 @7 "Sample size 7: " n7 8 ATTR=underline COLOR=Blue #34 @40 "Sample size 8: " n8 8 ATTR=underline COLOR=Blue #35 @7 "Sample size 9: " n9 8 ATTR=underline COLOR=Blue #35 @40 "Sample size 10: " n10 8 ATTR=underline COLOR=Blue GROUP=nreps #38 @3 "Number of Replicates" #40 @7 "Please enter the number of simulated data sets for each" #41 @7 "alternative and sample size:" nreps 8 ATTR=underline COLOR=Blue ; %window output IROW=2 ICOLUMN=2 ROWS=50 COLUMNS=70 group=any #3 @3 "By default, this macro produces only SAS data sets. You can" #4 @3 "choose to print a table of power estimates, a table of" #5 @3 "estimated number of subjects, and/or graphical output." #7 @3 "Would you like to print a table with power estimates?" #8 @7 est1 1 ATTR=UNDERLINE COLOR=Blue @9 "Yes" #9 @7 est2 1 ATTR=UNDERLINE COLOR=Blue @9 "No" #11 @3 "Would you like to print a table with the number of subjects" #12 @3 "required for power of .1, .2, ... .9?" #13 @7 nsubs1 1 ATTR=UNDERLINE COLOR=Blue @9 "Yes" #14 @7 nsubs2 1 ATTR=UNDERLINE COLOR=Blue @9 "No" group=graphtype #16 @3 "Graphical output plots power vs. sample size for each alternative" #17 @3 "and requires SAS/GRAPH." #19 @3 "Which type of graphical output would you like?" #20 @7 graph1 1 ATTR=UNDERLINE COLOR=Blue @9 "None" COLOR=Blue #21 @7 graph2 1 ATTR=UNDERLINE COLOR=Blue @9 "One plot with a curve for each alternative" COLOR=Blue #22 @7 graph3 1 ATTR=UNDERLINE COLOR=Blue @9 "One small plot for each alternative (requires SAS 9.2)" COLOR=Blue group=sg #23 @11 "How many rows would you like?" plotrows 3 ATTR=underline COLOR=Blue ; %window summary IROW=2 ICOLUMN=2 ROWS=50 COLUMNS=70 group=final #12 @3 "Please choose from the following options:" #14 @7 cont1 1 ATTR=UNDERLINE COLOR=Blue @9 "All information is correct. Please start the Monte Carlo" #15 @9 "power calculations." #16 @7 cont2 1 ATTR=UNDERLINE COLOR=Blue @9 "Some information needs to be corrected. Please go back to" #17 @9 "the beginning so that I can make corrections." #18 @7 cont3 1 ATTR=UNDERLINE COLOR=Blue @9 "I do not want to run the Monte Carlo power calculations at" #19 @9 "this time. Please exit this window." ; %macro varselect(); %let outcomedist=; %let scaley=; %let intercept=; %let out1=; %let out2=; %let out3=; %let xdist=; %let xloc=; %let xscale=; %let pred1=; %let pred2=; %let pred3=; %let pred4=; %let pred5=; %let pred6=; %let pred7=; %let pred8=; %let nullhyp=; %let alt1=; %let alt2=; %let alt3=; %let n1=; %let n2=; %let n3=; %let n4=; %let n5=; %let n6=; %let n7=; %let n8=; %let n9=; %let n10=; %let nreps=; %let est1=; %let est2=; %let nsubs1=; %let nsubs2=; %let graph1=; %let graph2=; %let graph3=; %let plotstyle=; %let plotrows=; %let printest=No; %let printnsubs=No; %let null=; %display intro; %outcomestrt:; %let cont1=; %let cont2=; %let cont3=; %display distributions.outcome BLANK; %if (&out1 ne &null)+(&out2 ne &null)+(&out3 ne &null) ne 1 %then %do; %display distributions.distErr BELL; %goto outcomestrt; %end; %else %do; %if &out1 ne &null %then %do; %let outcomedist = "normal"; %display distributions.ynorm; %let intercept=.; %end; %else %if &out2 ne &null %then %do; %let outcomedist = "poisson"; %display distributions.ypois; %let scaley=.; %end; %else %if &out3 ne &null %then %do; %let outcomedist = "bernoulli"; %display distributions.ybern; %let scaley=.; %end; %end; %predstrt:; %display distributions.predictor; %if (&pred1 ne &null)+(&pred2 ne &null)+(&pred3 ne &null)+(&pred4 ne &null)+(&pred5 ne &null)+(&pred6 ne &null)+(&pred7 ne &null)+(&pred8 ne &null) ne 1 %then %do; %display distributions.distErr BELL; %goto predstrt; %end; %else %do; %if &pred1 ne &null %then %do; %let xdist = 'normal'; %display distributions.xnorm; %end; %else %if &pred2 ne &null %then %do; %let xdist = 'poisson'; %display distributions.xpois; %end; %else %if &pred3 ne &null %then %do; %let xdist = 'bernoulli'; %display distributions.xbern; %end; %else %if &pred4 ne &null %then %do; %let xdist = 'binomial'; %display distributions.xbin; %end; %else %if &pred5 ne &null %then %do; %let xdist = 'beta'; %display distributions.xbeta; %end; %else %if &pred6 ne &null %then %do; %let xdist = 'exponential'; %display distributions.xexp; %end; %else %if &pred7 ne &null %then %do; %let xdist = 'uniform'; %display distributions.xuni; %end; %else %if &pred8 ne &null %then %do; %let xdist = 't'; %display distributions.xt; %end; %end; %if &xloc eq &null %then %let xloc=.; %if &xscale eq &null %then %let xscale=.; %if &outcomedist = "normal" %then %display misc.hypothesesnorm BLANK; %else %if &outcomedist = "poisson" %then %display misc.hypothesespois BLANK; %else %if &outcomedist = "bernoulli" %then %display misc.hypothesesbern BLANK; %do i=1 %to 3; %if &&alt&i eq &null %then %let alt&i=.; %end; %display misc.samplesize; %do j=1 %to 10; %if &&n&j eq &null %then %let n&j=.; %end; %display misc.nreps; %display output.any; %if &est1 ne &null %then %let printest = Yes; %if &nsubs1 ne &null %then %let printnsubs = Yes; %display output.graphtype; %if &graph2 ne &null %then %let plotstyle = graphic; %else %if &graph3 ne &null %then %do; %let plotstyle = sg; %display output.sg; %end; %display summary.final; %if &cont2 ne &null %then %goto outcomestrt; %if &cont3 ne &null %then %goto exit; data _null_; if &outcomedist eq "normal" then nullhyp = &nullhyp; else nullhyp = compress(log(&nullhyp)); call symput('null', nullhyp); run; %manypower(alt1=&alt1, alt2=&alt2, alt3=&alt3, n1=&n1, n2=&n2, n3=&n3, n4=&n4, n5=&n5, n6=&n6, n7=&n7, n8=&n8, n9=&n9, n10=&n10, null=&null, scaley=&scaley, xdist=&xdist, xloc=&xloc, xscale=&xscale, nreps=&nreps, plotrows=&plotrows, plotstyle=&plotstyle, outputpower=&printest, outputnsubs=&printnsubs, outcomedist=&outcomedist, descending=desc, intercept=&intercept); %exit:; %mend varselect; %varselect; /* %window verify IROW=10 ICOLUMN=20 ROWS=15 COLUMNS=60 #3 @5 "You have chosen the following: " / @5 wines PROTECT=YES // @5 "Is this correct (Y/N)?" +3 ansr 1 ATTR=UNDERLINE REQUIRED=YES ; %IF &vino1 NE &null %THEN %LET vino1=BURGUNDY; %IF &vino2 NE &null %THEN %LET vino2=MERLOT; %IF &vino3 NE &null %THEN %LET vino3=ZINFANDEL; %IF &vino4 NE &null %THEN %LET vino4=RIESLING; %let wines=&vino1 &vino2 &vino3 &vino4; %LET ansr = &null; %DISPLAY verify BELL; %IF %UPCASE(&ansr) NE Y %THEN %GOTO lblstrt; */ /* %manypower(outcomedist="bernoulli", intercept=.5, xdist = "exponential", nreps = 100, n1=20, n2=30, n3 = 50, n4 = 75, n5 = 100, alt1=2, alt2=3, plotstyle=sg); %manypower(outcomedist="poisson", intercept = 1, xdist = "bernoulli", xloc=.5, nreps = 100, n1 = 1000, n2 = 1200, n3 = 1400, n4 = 1600, n5 = 1800, n6 = 2000, alt1 = 1.15, alt2 = 1.2, alt3 = 1.25, plotrows=2,plotstyle=graphic); %manypower(outcomedist="poisson", intercept = 1, xdist = "bernoulli", xloc=.5, nreps = 50, n1 = 500, n2 = 1000, n3 = 1500, n4 = 2000, n5 = 2500, alt1 = 1.15, plotrows=2,plotstyle=graphic); */