proc iml; options nodate pagesize=60 linesize=80; *This program generates a sampling distribution of means from a normal distribution. You need to input parameters mu (population mean) SD (population SD) N (sample size) and number of samples Nsam; *input mu, the population mean; mu1 = 50; mu2 = 55; *input SD, the population standard deviation; SD1= 20; SD2= 20; *Input the sample size per sample for the sampling distribution; N1 = 50; N2 = 50; *Input the number of samples to be included in the sampling distribution; Nsam=1000; out1 = j(Nsam,3,-999); do h=1 to Nsam; * Set for Nsam iterations; sample1 = normal(j(N1,1,0)); *print sample; sample1 = sample1*SD1+j(N1,1,mu1); mean1=sample1[+,]/N1; out1[h,1]=mean1; *******; sample2 = normal(j(N2,1,0)); *print sample; sample2 = sample2*SD2+j(N2,1,mu2); mean2=sample2[+,]/N2; out1[h,2]=mean2; out1[h,3]=mean1-mean2; 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; proc univariate plot normal; run;