Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Re: Tactical looping


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Re: Tactical looping
Date   Mon, 26 Jan 2004 15:20:57 -0000 (GMT)

All,

Michael Blasnik wrote:

>> use mydata
>> reshape long @pc, i(id) j(party) string
>> bysort id (pc): gen byte rank=_N-_n+1
>> keep if rank<4
>> keep id party rank
>> reshape wide  party, i(id) j(rank)
>> sort id
>> save top3
>> use mydata
>> sort id
>> merge id using top3
>> assert _merge==3
>>
>> This assumes your file is called mydata and that there is some sort of
>> election id variable, called id.  It keeps the top 3 as
>> party1 party2 and
>> party3.

Ah. I forgot to mention something (but, in my defence, I didn't think it
would be crucial!). Many of my cases contain missing values for at least
one of the parties (particularly English seats, where there are no
equivalents to the Nationalist parties). In the cases where no Nationalist
candidate appears, the orderings turn out all wrong!

So what would I change in the above code to handle the missings? Sincere
apologies for any confusion.

CLIVE NICHOLAS        |t: 0(44)191 222 5969
Politics Building     |e: [email protected]
School of Geography,  |f: 0(44)870 126 2421
 Politics & Sociology |
University of         |
 Newcastle-upon-Tyne  |
Newcastle-upon-Tyne   |
NE1 7RU		      |
United Kingdom	      |http://www.ncl.ac.uk/geps
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index