Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: More than 2 arguments for by


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: More than 2 arguments for by
Date   Tue, 16 Sep 2008 15:39:18 +0100

Neil Shephard and Martin Weiss made helpful comments. 

My guess is that what Ashim needs is 

bysort year state cnum (votes) : keep if _n == _N 

except that his report "I have ." leads me to guess that he has missing
values, which would be problematic with that code. 

Missing values are sorted to the end of any block of observations, as
they are treated as arbitrarily large. So missing values will show up in
the kept data for every constituency (if that is what -cnum- indexes)
for which they exist. 

Even if this guess is correct, it raises two questions. 

1. Why does Ashim have missings? Are they something else, e.g. zeros? If
so, they should be fixed. 

2. If the missings are genuine, they need to be fixed before -sort-ing.
Ashim's purpose seems to call for 

drop if missing(votes) 

Also -search dropmiss-. 

Nick 
[email protected] 

Ashim Kapoor

I want to do the following :

sort year state cnum votes

by year stata cnum votes : keep if _n==_N

That way I get the guy with the max no of votes.

Now when I do this for 1 or 2 arguments for by then it works, but not
for 4 arguments I have . Does by have a limit on how many arguments it
can have ?

I read -help by- and that does mention using by in the following
fashion : -- > by year ( state) . Do I need to put in brackets for the
other arguments?

Could someone please clarify?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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