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 (April 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 Apr 2008 12:48:33 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: anybody can help with this function?
Comments: To: Sigurd Hermansen <HERMANS1@westat.com>
In-Reply-To:  <CA8F89971ADA9F47A6C915BA2397844207B426AB@MAILBE2.westat.com>
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Apr 18, 2008 at 12:30 PM, Sigurd Hermansen <HERMANS1@westat.com> wrote: > /* Only for purpose of showing random value and that same seed > generates same series. */

You don't have that quite right. The second call in your example uses the same stream as the first. Thus the two call do NOT produce the same random number. You have to use call ranuni for that see next example.

It goes something like this. assign a seed. Call the function. The function actually return 2 numbers one is the random number the other is the seed for the next call. For the function form SAS just has one place to hold the seed. So other calls use the same value and update the seed.

data _null_; do i=1 to 100; y0 = ranuni(12371); if y0>0.5 then y=1; else y=0; /* Ranuni function uses just one stream*/ x=ranuni(12371); put i= x= y0= y= ; end; run;

data _null_; retain seed1 seed2 12371; do i=1 to 100; call ranuni(seed1,y0); if y0>0.5 then y=1; else y=0; /* call Ranuni allows different streams*/ call ranuni(seed2,x); put i= x= y0= y= seed1= seed2=; end; run;


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