Date: Tue, 14 Sep 2010 02:27:18 +0100
Reply-To: John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject: Re: how to generate 1 to 100k random numbers without zeros?
In-Reply-To: <201009132350.o8DKPMSk031339@willow.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 19:50 13/09/2010 -0400, Arthur Tabachneck wrote:
>John,
>
>Nice to see you back again!
Thanks. I've never stopped monitoring/reading SAS-L, but time to actually
contribute has been sadly lacking in recent years!
>This thread actually (as I recall at least) started on comp.soft-sys.sas.
>The OP, at it turned out, wanted random numbers between 1 and 100,000,
>with replacement.
>
>As datanull pointed out, in that thread, without replacment proc plan
>provided a much easier alternative. Any of the other solutions, using
>only the ranuni function, would result in duplication.
Indeed. PROC PLAN is now the obvious solution if one wants 'without
replacement'. However, for those who 'want to see what is going on' or for
those of us who often forget that we are not still in the pre-PROC-PLAN
era, with only 100,000 numbers to choose from (and provided the sample size
needed is a lot less than 100,000), a brute force method using ranuni() and
an array look-up to avoid duplication would be very simple to implement and
would run very quickly.
Kind Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
Buckingham MK18 4EL, UK
----------------------------------------------------------------
|