Date: Tue, 2 Dec 2003 14:23:16 -0500
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: ***PROBLEM USING RANUNI AND FLOOR FUNCTION TO CREATE FAKE DAT
A***
Content-Type: text/plain
Cybie,
The RANUNI function has one seed stream in the DATA step. You apprently
want two streams the same. You could use the corresponding CALL routine
with two seeds starting with the same value. Or simpler,
data sales1;
do i=1 to 5;
Check=(ranuni(12345)*6);
Prod_Num=floor(check);
output;
end;
run ;
proc print data=sales1;
run;
IanWhitlock@westat.com
-----Original Message-----
From: Cybie Frontier [mailto:cybie@HOTMAIL.COM]
Sent: Tuesday, December 02, 2003 2:13 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: ***PROBLEM USING RANUNI AND FLOOR FUNCTION TO CREATE FAKE DATA***
Hi Folks:
This is kind of perplexing but I am sure there is definitely a logical
explanation for it. I have been trying to generate some fake data using the
following code. The "Check" variable is there to check the value of the
variable before the floor function is applied to it.
data sales1;
do i=1 to 5;
Prod_Num=floor(ranuni(12345)*6);
Check=(ranuni(12345)*6);
output;
end;
proc print data=sales1;
run;
The output that I am getting is:
Obs i Prod_Num Check
1 1 2 4.47117
2 2 4 1.65766
3 3 1 4.37330
4 4 0 4.40591
5 5 4 4.58448
Now, if I apply the floor function to 4.47117 I should get 4 and not 2 as in
OBS 1. But The Prod_Num is 2 in OBS=1. Similar anomalies exist for all other
obs. What is the explanation for this anomaly?
Thank you very much for your help.
- CF
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail