Date: Thu, 13 Apr 2000 16:39:49 GMT
Reply-To: sashole@mediaone.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject: Re: random number generator
Content-Type: text/plain; format=flowed
Ray,
You are right, although Christy might have been interested in a kind of
macro expression that would, for instance, return a randomly generated
number into a macro variable (rather than in a DATA step expression). If
this is the case, transforming your expression into a macro one is
straightforward:
%macro r (n,seed);
%sysfunc(ceil(%sysfunc(ranuni(&s))*&n))
%mend r;
Here is, e.g., a piece of log:
23 %put %r(9999999999,0);
9757723719
Kind regards,
====================
Paul M. Dorfman
Jacksonville, Fl
====================
>From: "Raymond V. Liedka" <liedka@UNM.EDU>
>Reply-To: "Raymond V. Liedka" <liedka@UNM.EDU>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: random number generator
>Date: Thu, 13 Apr 2000 09:30:46 -0600
>
>On Thu, 13 Apr 2000, Christy Gaughan wrote:
>
> > Does anyone have a macro to generate a random number (integer) between
> > 1 and n, using the uniform distribution? N is very large. I am not
> > interested in using ranuni with if then else statements, unless it is
> > in a macro form. Thanks in advance.
> >
> > Christy
> >
>
>how about something like this:
>
>number = int(ranuni(seed)*n)+1;
>
>
>where seed is 0 to use the clocktime, or some seed number you assign for
>the random number generator.
>
>
>ray
>
>
>
>Raymond V. Liedka
>Assistant Professor
>Department of Sociology
>University of New Mexico
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
|