* eg2.sas: pseudo-random data, do loops, and output statement; options linesize=80; ; * simulate 10 random samples of size 5 from the uniform distribution on * (0,100) and compute the mean of each sample; data uniform; seed=79851; * seed for random number generator; array x(5); * array of observations in each sample; do sample=1 to 10; * loop to generate 10 samples; do i=1 to 5; * loop for 5 observations per sample; x(i)=ranuni(seed)*100; * ith observation in current sample; end; * "i" loop; * compute sample mean for sample size n=5; sum=0; do i=1 to 5; sum=sum+x(i); end; xbar=sum/5; output; * create an observation/row in the SAS data set; end; * "sample" loop; ; * print the data; proc print; var x1-x5 xbar; The SAS System 1 11:33 Monday, September 4, 2006 Obs x1 x2 x3 x4 x5 xbar 1 44.6163 55.4033 37.0666 24.1232 88.7445 49.9908 2 76.5655 42.9955 11.5759 10.2787 40.5712 36.3974 3 40.7179 58.5010 38.9116 75.5642 31.2054 48.9800 4 23.5231 32.3969 57.0959 65.1029 85.1863 52.6610 5 37.6777 60.7490 10.4454 25.2241 25.1797 31.8552 6 5.5099 38.5382 20.9205 71.7465 89.4542 45.2339 7 39.8920 79.8430 33.6695 16.5095 96.7644 53.3357 8 54.1502 12.9349 94.2102 81.0520 2.2915 48.9278 9 27.5851 59.6308 64.3036 7.9460 49.6320 41.8195 10 92.8695 27.0325 85.8258 24.4269 81.7603 62.3830