LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 16 Jul 2011 15:14:38 -0700
Reply-To:     Daniel Nordlund <djnordlund@FRONTIER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Daniel Nordlund <djnordlund@FRONTIER.COM>
Subject:      Re: the "standard" code generating a sample
In-Reply-To:  <4E220621.2070908@gmail.com>
Content-Type: text/plain; charset="UTF-8"

see comments below

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Mark > Miller > Sent: Saturday, July 16, 2011 2:44 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: the "standard" code generating a sample > > Max, > > Correction to my previous post > The sample procedure is for SRS w Replacement > due to use of POINT rather than sequential reads > Not sure if Knuth covers this variant since > I no longer have a copy to consult. > > ... Mark >

No, the algorithm is for SRS without replacement. The pointer value pickit runs consecutively from 1 to (potentially) totalobs. It never repeats.

Hope this is helpful,

Dan

Daniel Nordlund Bothell, WA USA

> On 7/16/2011 2:11 PM, bbser 2009 wrote: > > I just realized I should have asked more specific questions about the > > standard code. > > So here we go: > > 1. What's the purpose of the if expression? > > 2. why do we need to this statement obsleft+(-1); > > 3. How does this algorithm avoid picking up the same obs more than once? > > > > Thank you. > > > > Max > > (Maaxx) > > > > -----Original Message----- > > From: bbser 2009 [mailto:bbser2009@gmail.com] > > Sent: July-16-11 4:47 PM > > To: 'SAS-L@LISTSERV.UGA.EDU' > > Subject: the "standard" code generating a sample > > > > Greetings! > > > > Basically speaking, the code below comes from the advanced certification > > book. > > This code are suppose to get a sample of size 10 from the pool. > > But I do not understand the algorithm, especially the if expression. > > Could you please explain the algorithm to me? Thank you very much! > > > > Max > > (Maaxx) > > > > ====================== > > > > data pool; > > do pop=1 to 1000; > > output; > > end; > > run; > > > > data sample(drop=obsleft samplesize); > > samplesize=10; > > obsleft=totobs; > > do while(samplesize>0); > > pickit+1; > > if ranuni(0)<samplesize/obsleft then > > do; > > set pool point=pickit nobs=totobs; > > output; > > samplesize=samplesize-1; > > end; > > obsleft+(-1); > > end; > > stop; > > run; > > > > proc print data=sample; > > run;


Back to: Top of message | Previous page | Main SAS-L page