Date: Tue, 30 Jan 2007 12:26:20 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: Random number generation
On Tue, 30 Jan 2007 11:14:44 -0500, Ankur Shanker
<ankur.shanker@EVALUESERVE.COM> wrote:
>Hello Everyone!
>
>I want to randomize a dataset i.e. i just want to randomly re-order all the
>observations (1673626). I am trying to do that with the the help of the
>following dataset.
>
>data rangen;
>do i=1 to 1673626 ;
>j=int(ranuni(0)*&n.);
>output;
>end;
>run;
>
>But, the only problem is that the values of j are not all unique. There are
>around 10000 duplicates everytime i run the above data step. So, is there a
>way, say, to get random numbers generated in a range (a,b) with (b-a+1)
>unique values.
>
>Regards,
>Ankur
I think you are better off without the INT function. Then there is no need
for the multiplication either.
If all you want to do is re-order, it's easier with SQL.
proc sql;
create table randomclass as
select * from sashelp.class
order by ranuni(0);
quit;
|