Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: how to generate a variable where one third of values would be randomly assigned


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to generate a variable where one third of values would be randomly assigned
Date   Mon, 12 Dec 2011 15:39:57 +0000

gen foo = cond(runiform() < 1/3, ceil(120 * runiform()), 120)

?

Nick

On 12 Dec 2011, at 15:04, Ekaterina Hertog <[email protected] > wrote:

Dear all,
I use stata 11 and I need to generate a variable where two thirds of observations (about 1300 obs) will be equal to 120 and the rest of the values are randomly assigned, but are all integers and less than 120.
Any advice will be very much appreciated,
Ekaterina
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index