Statapeep,
Not that elegant, and might be problematic should the data show a tie, but:
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
Clive Nicholas wrote:
Statapeeps,
Yeah, I know, I know. I'm being greedy!! But this problem may tickle your
fancy. :-)
In my very same dataset, I'm looking to dummy-code (0/1) which party won
the ith seat in the jth election. Since this is Blighty, there can only be
one winner per district, but since that n=3452, that's an awful lot of
outcomes to code manually! There are five outcome categories: conwin;
labwin; ldmwin; natwin; and othwin.
Now here's the rub: since it's plurality-rule, I need to tell Stata to
code, say, conwin=1 and labwin-othwin=0 if, say, for district X: conpc=35;
labpc=31; ldmpc=16; natpc=17; othpc=1. I've tried several generates, such
as:
-g conwin=0 if conpc > labpc & ldmpc & natpc & othpc-
-replace conwin=1 if conpc < labpc & ldmpc & natpc & othpc-,
but, although Stata did not return errors at *any* of my 'solutions', each
kept producing multiple, rather than unique, 1's for each case (or n).
Any ideas as to where I'm going wrong?
Yours,
CLIVE NICHOLAS,
Politics Building,
School of Geography, Politics and Sociology,
University of Newcastle-upon-Tyne,
Newcastle-upon-Tyne,
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/
*
* 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/