options ps=65;
/*This program computes the sample size necessary to achieve target levels of accuracy
for correlation and partial correlation coefficients such as are reported in Table 1 in
Algina and Olejnik (2003).
The population correlation can be changed by changing .00 in the code rho = .00;
The number of control variables can be changed by changing 0 in the code q=0;
The probability can be changed by changing .95 in the code p=.95;
The target levels of accuracy can be changed by changing .05 in the code c = .05;
*/
data gen;
rho = .00;
q=0;
p=.95;
c = .05;
rhotid=rho/(sqrt(1-rho**2));
do nn=q + 3 to 100000;
n=nn;
df=n-q-2;
rul=rho+c;
rll=rho-c;
if rul>=1.0 then rul=.99999;
rtul=rul/(sqrt(1-rul**2));
rtll=rll/(sqrt(1-rll**2));
g=sqrt(2*(1-rho**2)/(2-rho**2));
deltasq=((2*(n-q)-3)*rho**2)/(2-rho**2);
delta=sqrt(deltasq);
ul=(sqrt(df)*g*rtul);
sl=(sqrt(df)*g*rtll);
pu=probt(ul,df,delta);
pl=probt(sl,df,delta);
if pu-pl >= p then do;
output;
nn=100000;
end;
end;
proc print;
var rho q c p rll rul n ;
title 'The Harley Approximation';
run;
quit;