Dear Statalisters,
I have three variables within each observation that I am trying to assign a
value for a new variable based on which of my three variables have the
highest value. If the highest value is pl, I would like to assign newvar =
0, if the highest value is pd: newvar = 1, or if the highest value is pu:
newvar = 0.5. However, if there's a tie for the highest value, I would like
to randomly choose the winner and then assign the value as above.
Here's an example of the data and what I would want newvar to indicate. I
would greatly appreciate any assistance. Thank you.
Id pd pl pu newvar
117 11 11 8 (1 or 0 based on whether
pd or pl win toss)
118 12 8 10 1
120 18 10 14 1
121 6 11 7 0
122 4 9 9 (0 or 0.5 based on
whether pl or pu win toss)
123 6 8 10 0.5
126 9 9 12 0.5
127 10 7 10 (1 or 0.5 based on
whether pd or pu win toss)
129 9 11 10 0
131 9 5 4 1
132 4 5 9 0.5
*
* 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/