Statalist The Stata Listserver


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

st: Re: Re: how to keep maximum value


From   "Rodrigo A. Alfaro" <[email protected]>
To   <[email protected]>
Subject   st: Re: Re: how to keep maximum value
Date   Sun, 24 Sep 2006 22:42:24 -0400

An alternative

collapse (max) var1, by(year)

----- Original Message ----- 
From: "Michael Blasnik" <[email protected]>
To: <[email protected]>
Sent: Sunday, September 24, 2006 10:01 PM
Subject: st: Re: how to keep maximum value



bysort year (var1): keep if _n==_N

Michael Blasnik

----- Original Message ----- 
From: "FUKUGAWA, N." <[email protected]>
To: <[email protected]>
Sent: Sunday, September 24, 2006 9:33 PM
Subject: st: how to keep maximum value


> Dear all,
> Suppose we have data as follows,
> 
> year var1
> 1997 14 
> 1997 32 
> 1997 19 
> 1998 18 
> 1998 42 
> 1998 50 
> 1999 3 
> 1999 23 
> 1999 37 
> 
> we want to keep observations by year if var1 is maximum within
> the same year.
> 
> year var1
> 1997 32 
> 1998 50 
> 1999 37 
> 
> How can I do this using stata9?
> Thank you in advance.
> ---
> FUKUGAWA Nobuya, Ph.D.
> [email protected]

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index