Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Generating Random Number


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Generating Random Number
Date   Tue, 23 Jan 2007 22:08:43 -0000

These are details you can keep hidden from us. Often
the simplest approach is to map irregular ids to 
regular ids 1 up which you then use for sampling. 
There are many ways to do that, including -egen, group()-. 
Whether you translate back to the irregular ids 
is then up to you. 

Nick 
[email protected] 

Raphael Fraser
 
> I am only interested in uniqueness.
> 
> I have 100 patients with ids 1-200. There are two observations per id.
> I would like to generate another id which I call bsid which ranges
> between 301-500.
> 
> On 1/23/07, Marcello Pagano <[email protected]> wrote:
> > What other properties do you want these numbers to have?
> > How many do you need?  If it is just uniqueness that you
> > want you might try random permutations of the integers
> > between 50 and 100.  That you can do with Stata.
> >
> > m.p.
> >
> > Raphael Fraser wrote:
> > > How do I generate random numbers between say, 50-100 that do not
> > > repeat themselves?  I have used the following code but 
> this allow the
> > > numbers to repeat themselves:
> > >
> > > gen bsid=50*int(50*uniform()+0.5)

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index