| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Quick Question on how to drop individual observations
From |
"Michael Blasnik" <[email protected]> |
To |
<[email protected]> |
Subject |
Re: st: RE: Quick Question on how to drop individual observations |
Date |
Fri, 16 Jun 2006 13:28:22 -0400 |
Your original query was ambiguous. The solution is now simpler:
bysort hhold rd: drop if _n==1 & _n<_N
will drop the first observation if there are duplicates on hhold and rd. If
you only want to keep the last observation (in case there are triplets or
more) then:
bysort hhold rd: keep if _n==_N
Michael Blasnik
[email protected]
----- Original Message -----
From: "JEFFREY ROSEN" <[email protected]>
To: <[email protected]>
Sent: Friday, June 16, 2006 12:44 PM
Subject: Re: st: RE: Quick Question on how to drop individual observations
Thanks for the quick reply. Unfortunately, the code didn't work as I had
hoped.
The dataset is drawn up as:
obs 1 hhold 1 rd 1
obs 2 hhold 1 rd 2
obs 3 hhold 1 rd 2
obs 4 hhold 1 rd 3
The code below will drop the observation where the hhold value and the rd
value are the same. So in the above example, hhold = rd = 1 at observation
1. Observation 1 was dropped. What I would like is to drop observation 2
because in observation 2, the identifiers are the same as observation 3.
Thanks for your help,
Jeff Rosen
*
* 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/