OPTIONS LINESIZE=88 PAGESIZE=53 NOCENTER NODATE NONUMBER NOFMTERR; *************************************************************************; * PROJECT NAME: Selecting Samples without Replacement in SAS ; * PROGRAM NAME DATE PROGRAMMER ; TITLE1 "Source:lec25p3.sas C:\ed\web\be691f\webready 12/3/98 EJS " ; * Description: Select a simple random sample of size 5 WITHOUT ; * replacement from a population of size N=10 ; *************************************************************************; ************************************; *** Generate a population of 10 ; *** ID numbers ; ************************************; DATA pop1; DO id=1 TO 10; OUTPUT; END; PROC PRINT; TITLE2 "Table 1. Original Population"; **************************************; *** Select a simple random sample of ; *** 5 observations without ; *** replacement ; *** from the 10 numbers ; **************************************; DATA samp1; SET pop1; RETAIN npop 10 nsamp 5; prob=nsamp/npop; *proportion of observations left to select; rn=RANUNI(3362); *random number to see if current obs is selected; IF rn LT prob THEN DO; insamp=1; *indicator for values selected in the sample; nsamp=nsamp-1; *number left to select in the sample; END; npop=npop-1; ****************************************; *** List the results of the Sampling *; ****************************************; PROC PRINT DATA=SAMP1; ID id; TITLE2 "Table 2. Population and Subjects Selected via "; TITLE3 " Simple Random Sampling without Replacement"; RUN;