Statalist


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

Re: st: creat random non-repeating


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: creat random non-repeating
Date   Sat, 8 Mar 2008 20:58:18 +0000 (GMT)

What about this:

*-------------- begin example ------------------
drop _all
set obs 20
gen obs = _n
gen unif = uniform()
sort unif
keep in 1/10
drop unif
list
*-------------- end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

--- Vincent Davis <[email protected]> wrote:

> I am trying to make a variable with random non-repeating integer obs 
> 
> in the range a to b.
>   Any suggestions
> Thanks
> Vincent
> Like this, where var1 is random non-repeating over the range 1-20
> OBS	Var1
> 1		4
> 2		7
> 3		2
> 4		20
> 5		12
> 6		15
> 7		18
> 8		17
> 9		11
> 10		1
> 
> *
> *   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/
> 


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
The World's Favourite Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   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