|
From | "Michael Blasnik" <michael.blasnik@verizon.net> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: Re: Re: RE: Re: generating random variable |
Date | Tue, 03 Apr 2007 15:16:34 -0400 |
The choice is random as coded -- that's why the code generates a random number and uses that in the sort. I guess you need a way to actually track where it was in the sort order to begin with..
expand 2
gen random=uniform()
gen choicenum=_n
bysort id bl set (random): gen byte choice=_n==_N
Now you can see that the choice is set randomly to one of the two values of choicenum in each set.
* * 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–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |