LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 May 2006 10:31:37 -0700
Reply-To:     "Nordlund, Dan (DSHS)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Data simulation functions and seeds
Comments: To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Content-Type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Howard Schreier <hs AT dc-sug DOT org> > Sent: Monday, May 22, 2006 6:52 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Data simulation functions and seeds > > On Mon, 22 May 2006 15:37:39 -0700, Nordlund, Dan (DSHS) > <NordlDJ@DSHS.WA.GOV> wrote: > > >> -----Original Message----- <<<snip>>>

> >Briefly, if you look at the resultant datasets from your simulation, you > >will see that the random numbers generated using either method are > >identical. This is because within a given data step, the seed is set > once > >and only once for a given random number generator when using the . So in > >your second example where you try to change the seed for the second > group, > >the new seed value is ignored. If you think that you need to change the > >seed (and the resulting pseudo-random number stream) you will need to use > >the syntax (see the SAS documentation) > Howard Schreier replied:

> Not sure what is meant by the apparent qualification "for a given random > number generator". My understanding is that there is one and only one > stream for the DATA step, and it's shared by all of the pseudorandom > number functions (RANNOR, RANUNI, RANthis, RANthat) and by all of the > references to each. >

Howard has correctly pointed out that when using the "function type" call to the random number generators,

e.g. x=ranuni(seed);

the seed is passed by value to the internal routines and the internal seed is set once and only once, and the internal seed value is shared among all random number generators used in the data step.

If one wants to maintain separate streams, that are based on separate seeds, one needs to use the "procedure call" type call:

Call ranuni(seed1,x); Call ranuni(seed2,y);

The stream of Xs will be unaffected by the stream of Ys in this case. This is because the seed value in this situation is passed by reference, and the "state" of the individual random number streams is maintained in separate seed variables.

Hope this adds more light than heat or smoke. :-)

Dan

Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204


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