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

Re: st: RE: Re: Tactical looping


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: RE: Re: Tactical looping
Date   Mon, 26 Jan 2004 11:50:56 -0500

I think you could just insert :

drop if pc==.

right after the 1st reshape command, that way missing vote percents won't
count as the highest.  Another approach would be to insert

replace pc=0 if pc==.

in the same spot, although this could conceivably declare a party in the top
3 if 0% is in the top 3 in any election.  Also, I just realized that the
approach I showed will split ties randomly so if you have any ties, you may
need to decide what to do about them.

Michael Blasnik
[email protected]

----- Original Message ----- 
From: "Clive Nicholas" <[email protected]>
To: <[email protected]>
Sent: Monday, January 26, 2004 10:20 AM
Subject: Re: st: RE: Re: Tactical looping


> 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


*
*   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