All,
Some months ago, I posted a question about what code I needed in order to
generate dummy codes to indicate whether or not a candidate won a constituency
election. In my dataset, I needed to do this for 3456 cases across 6
time-points. Many of you were generous in your response to this, including
Nick Cox, who supplied this loop:
egen max = rmax(conpc labpc ldmpc natpc othpc)
foreach x in con lab ldm nat oth {
egen `x'win=diff(`x'pc max)
recode `x'win (1=0) (0=1)
}
drop max
I don't think I've changed this, so hopefully it's still correct. *This _in no
way_ slights the other very helpful solutions given to me.* This has served me
superbly over the months, but on reading an old BJPS article about the
potential effects of tactical voting on consitituency outcomes at general
elections, I realised I'd made a quite stupid omission: I'd coded the winners,
but _not_ the candidates who finished second and third!
Looking at -help mathfun-, the only relevant operators here are -max- and
-min- (as far as I can tell). Obviously, -max- cannot be used, and it would be
rather dicy to use -min- (since different parties finish in different places
in different seats at different times). Therefore, is there a solution? I'm
lost! Thanks.
Yours,
CLIVE NICHOLAS,
Politics Building,
School of Geography, Politics and Sociology,
University of Newcastle-upon-Tyne,
Newcastle,
NE1 7RU,
United Kingdom.
*
* 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/