/*This program computes the sample size necessary to achieve target power
for correlation and partial correlation coefficients such as are reported in Tables 4 and 5 in
Algina and Olejnik (2003).
The population correlation coefficient can be changed by changing .05 in the code rho=.05.
The Type I error rate can be changed by changing .05 in the code alpha=.05;
The target powers can be changed by changing .70 the code tpower =.70;
The number of tails can be changed by changing 2 to 1 in the code ntails=1;
The number of control variables can be changed by changing 0 in the code q=0;
*/
data;
rho=.05;
alpha=.05;
tpower=.70;
ntails=2;
q=0;
do n = q + 3 to 100000;
if ntails=2 then prob=1-alpha/2;
else prob=1-alpha;
df=n-q-2;
cval=tinv(prob,df);
g=sqrt(2*(1-rho**2)/(2-rho**2));
deltasq=((2*(n-q)-3)*rho**2)/(2-rho**2);
delta=sqrt(deltasq);
p=1-probt(g*cval,df,delta);
if p>=tpower then do;
power=round(tpower,.01);
output;
n=100000;
end;
end;
n=n+q;
proc print;
var rho alpha q tpower n power;
Title 'The Harley Approximation';
run;
quit;