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 (December 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 2 Dec 2003 14:30:51 -0500
Reply-To:   Kevin Roland Viel <kviel@EMORY.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Kevin Roland Viel <kviel@EMORY.EDU>
Subject:   Re: ***PROBLEM USING RANUNI AND FLOOR FUNCTION TO CREATE FAKE DATA***
In-Reply-To:   <Law15-F95pimHJ8Et3l00003cd6@hotmail.com>
Content-Type:   TEXT/PLAIN; charset=US-ASCII

CF,

Even though you are using the same seed, you will get different numbers in the series. To see this remove the FLOOR() function. You *will* get the same number upon separate invocations of the data step.

Think of the seed as identifying a series of numbers. Each call within a data step goes further down the list. A new data step re-starts the series:

36 data _null_; 37 do i=1 to 5; 38 x=ranuni(10); 39 y=ranuni(10); 40 put i= x= y=; 41 end; 42 run;

i=1 x=0.8496256982 y=0.7008871565 i=2 x=0.9982430609 y=0.5939864538 i=3 x=0.2160257787 y=0.6927734975 i=4 x=0.4297917315 y=0.3169172282 i=5 x=0.4979402621 y=0.665665516 NOTE: DATA statement used: real time 0.00 seconds cpu time 0.00 seconds

43 44 45 data _null_; 46 do j=1 to 10; 47 x=ranuni(10); 48 put j= x=; 49 end; 50 run;

j=1 x=0.8496256982 j=2 x=0.7008871565 j=3 x=0.9982430609 j=4 x=0.5939864538 j=5 x=0.2160257787 j=6 x=0.6927734975 j=7 x=0.4297917315 j=8 x=0.3169172282 j=9 x=0.4979402621 j=10 x=0.665665516 NOTE: DATA statement used: real time 0.00 seconds cpu time 0.00 seconds

To avoid your problem assign the call to a variable and work from there:

data sales1; do i=1 to 5; ranuni=ranuni(12345)*6; Prod_Num=floor(ranuni); output; end; run;

Regards,

Kevin

Kevin Viel Department of Epidemiology Rollins School of Public Health Emory University Atlanta, GA 30322


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