proc iml; options nodate pagesize=60 linesize=80; *This program generates a sampling distribution of correlation coefficients. You need to input parameter rho, the sample size N, and the number of samples Nsam; *input rho in matrix r in the off diagonal both above and below:; r= {1 .3, .3 1}; rho1 = r[2,1]; *Input the sample size; N=30; *Input the number of smaples; Nsam=10000; print 'input data'; print 'rho is' rho1; print 'sample size is' N; print 'iterations = ' Nsam; out1 = j(Nsam,1,-9); do h=1 to Nsam; * Set for Nsam iterations; sample = normal(j(N,2,0)); sample = sample*half(r); corr1=corr(sample); out1[h,]=corr1[2,1]; end; *create output datasets; create out2 from out1; append from out1; quit; data d2; set out2; *If you want to save the distribution, write to an external file; *file 'c:/sas/mike/corrs'; *put col1 8.4; ************************************************** *power analysis; **************************************************; min = .26; result = 0; if col1 gt min then result = 1; proc univariate plot normal; run;