| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Re: RE: Re: generating random variable
Dear Michael,
Thank you for all the help and the explanations
Manos
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Blasnik
Sent: 03 April 2007 20:17
To: [email protected]
Subject: st: Re: Re: RE: Re: generating random variable
woops, please change :
gen choicenum=_n
into
bysort id bl set : gen choicenum=_n
----- Original Message -----
From: "Michael Blasnik" <[email protected]>
To: <[email protected]>
Sent: Tuesday, April 03, 2007 3:12 PM
Subject: st: Re: RE: Re: generating random variable
> 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/
*
* 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/