```Date: Fri, 18 Apr 2008 14:09:23 -0400 Reply-To: Sigurd Hermansen Sender: "SAS(r) Discussion" From: Sigurd Hermansen Subject: Re: anybody can help with this function? Comments: To: "data _null_," In-Reply-To: <7367b4e20804181048t2ab739a4oc3b67b9fb827d477@mail.gmail.com> Content-Type: text/plain; charset="us-ascii" Yes. I guess I didn't phrase that quite right. Thanks for the correct interpretation and CALL example. S -----Original Message----- From: data _null_, [mailto:datanull@gmail.com] Sent: Friday, April 18, 2008 1:49 PM To: Sigurd Hermansen Cc: SAS-L@listserv.uga.edu Subject: Re: anybody can help with this function? On Fri, Apr 18, 2008 at 12:30 PM, Sigurd Hermansen 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