/*SAMPLE SIZE AND POWER calculators for ODDS RATIO (for case control study)*/ /*Caclulates sample size for fixed power or power for fixed sample size*/ /*Calculates sample size and power for a range of odds ratio values*/ /*Assumes two groups: cases and controls*/ /*Assumes binary exposure variable*/ /*Null hypothesis: proportion exposed is the same in cases and controls (=odds ratio is 1.0)*/ /*Assumes two-tailed test at .05 significance*/ /*Author: Kristin Cobb, March 2005*/ /*SAMPLE SIZE CALCULATOR: sample size from power: under different assumptions for the odds ratio*/ /*User enters: pcontrol = proportion of the control group that you expect to be exposed (*entered as a decimal, e.g. .50) power = how much statistical power you want (entered as a decimal, e.g. 0.80) r = ratio of the control group to the case group (e.g., 2 controls per cases) OR= Expected odds ratio due to exposure (e.g. odds ratio for exposed: unexposed) inc= expected percentage of the sample for whom you expect to have incomplete exposure data (entered as a decimal, e.g. .15) */ %macro samplesize3(pcontrol, power, r, OR, inc); data samplesize3; if &OR.>1 then do; do i=1.1 to &OR.+1 by .10; OR=i; pcase=(&pcontrol.*OR)/(1+&pcontrol.*(OR-1)); pavg=(pcase+&pcontrol.*&r.)/(1+&r.); Zbeta=probit(&power.); num=(1.96+Zbeta)**2; den=(pcase-&pcontrol.)**2; cases=ceil(((num*pavg*(1-pavg)*(&r.+1))/(&r.*den))/(1-&inc.)); controls=ceil((&r.*cases)); output; end; end; if &OR.<1 then do; do i=.1 to .90 by .10; OR=i; pcase=(&pcontrol.*OR)/(1+&pcontrol.*(OR-1)); pavg=(pcase+&pcontrol.*&r.)/(1+&r.); Zbeta=probit(&power.); num=(1.96+Zbeta)**2; cases=ceil(((num*pavg*(1-pavg)*(&r.+1))/(&r.*(pcase-&pcontrol.)**2))/(1-&inc.)); controls=ceil((&r.*cases)); output; end; end; run; proc print data=samplesize3 noobs; var OR cases controls; run; %mend samplesize3; /*example usage of sample size macro:*/ %samplesize3(pcontrol=.20, power=.80, r=.7, OR=.5, inc=0); /*POWER CALCULATOR: power from sample size: under different assumptions for the odds ratio*/ /*User enters: ncases = number of cases in the study ncontrols = number of controls in the study pcontrol = proportion of the control group that you expect to be exposed (*entered as a decimal, e.g. .50) OR= Expected odds ratio due to exposure (e.g. odds ratio for exposed: unexposed) inc= expected percentage of the sample for whom you expect to have incomplete exposure data (entered as a decimal, e.g. .15) */ %macro power3(ncases, ncontrols, pcontrol, OR, inc); data power3; if &OR.>1 then do; do i=1.1 to &OR.+1 by .10; OR=i; r=&ncontrols./&ncases.; pcase=(&pcontrol.*OR)/(1+&pcontrol.*(OR-1)); pavg=(pcase+&pcontrol.*r)/(1+r); den=(pcase-&pcontrol.)**2; num=(&ncases.*(1-&inc.)*den*r)/((r+1)*pavg*(1-pavg)); Zbeta=sqrt(num)-1.96; power=cdf('normal',Zbeta); output; end; end; if &OR.<1 then do; do i=.1 to .90 by .10; OR=i; r=&ncontrols./&ncases.; pcase=(&pcontrol.*OR)/(1+&pcontrol.*(OR-1)); pavg=(pcase+&pcontrol.*r)/(1+r); den=(pcase-&pcontrol.)**2; num=(&ncases.*(1-&inc.)*den*r)/((r+1)*pavg*(1-pavg)); Zbeta=sqrt(num)-1.96; power=cdf('normal',Zbeta); output; end; end; run; proc print data=power3 noobs; var OR power; run; %mend power3; /*example usage of power macro:*/ %power3(ncases=100, ncontrols=200, pcontrol=.20, OR=.7, inc=0);