I am not clear why you think that better.
Nick
[email protected]
Maarten buis
Even better would be:
gen unif = uniform()
gen which = cond(unif < 0.721, "A", ///
cond(unif < 0.923, "B", ///
cond(unif < 0.990, "C", "D")))
--- Nick Cox <[email protected]> wrote:
> This may help:
>
> . gen which = cond(uniform() < 0.721, "A",
> cond(uniform() < 0.923, "B",
> cond(uniform() < 0.990, "C", "D")))
>
> Also see
>
> SJ-7-3 pr0032 Stata tip 48: Discrete uses for uniform()
> M. L. Buis
> Q3/07 SJ 7(3):434--435
> tip on using uniform() to create random draws from a
> discrete distribution where each possible value has a
> known probability
>
*
* 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/