OPTIONS LINESIZE=88 PAGESIZE=53 NOCENTER NODATE NONUMBER NOFMTERR; *************************************************************************; * PROJECT NAME: Selecting Samples without Replacement in SAS ; * PROGRAM NAME DATE PROGRAMMER ; TITLE1 "Source:lec25p7.sas C:\ed\web\be691f\webready 12/3/98 EJS " ; * Description:Select a SRS of size 5 WITHOUT Rep from Pop of size 10 ; * keeping only the selected sample values ; * Illustrating the RETAIN statement using PUT statements ; *************************************************************************; **************************************; *** Select a simple random sample of ; *** 5 observations without ; *** replacement ; *** from the 10 numbers ; **************************************; DATA samp1; SET pop1; FILE PRINT ; * Direct output from PUT statements to OUTPUT window; npop=10; nsamp=5; RETAIN npop nsamp ; prob=nsamp/npop; *proportion of observations left to select; rn=RANUNI(3362); *random number to see if current obs is selected; PUT /ID= npop= nsamp= prob= rn= ; * details of data step; 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; PUT " Selected:" insamp= nsamp= npop= ; OUTPUT; END; npop=npop-1; PROC PRINT DATA=samp1; ID id; TITLE2 "Table 7.1 Illustratin of SRS without Replacement with WRONG use Initial Values for RETAIN"; RUN;