Statalist The Stata Listserver


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

Re: st: Dropping/Keeping observations


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Dropping/Keeping observations
Date   Sat, 22 Apr 2006 13:55:40 +0100 (BST)

Gauri:
The example below might do something like what you want. Assuem that rep78 is your id (with the
added observation created in the second line which should be dropped). _n is the current
observation number, while _N is the total number of observations in the category defined by -by-.
so -if _n==_N- means the last observation in that category, -_N>1- means if that category has more
than one observation, and rep78<. ensures that you only take nonmissing values of rep78.
HTH,
Maarten

*---------begin example------------
sysuse auto, clear
replace rep78 = 10 in 10 /*create a unique value in rep78*/
sort rep78
list rep78 in 1/10
by rep78: keep if _n==_N & _N>1 & rep78 <.
list rep78
*----------end example--------------

--- Gauri Khanna <[email protected]> wrote:
> I would like to KEEP those plots/observations 
> where farmerID appears more than once. Hence, I would like to DROP those 
> observations which have only one farmerID. Any tips?


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


		
___________________________________________________________ 
Switch an email account to Yahoo! Mail, you could win FIFA World Cup tickets. http://uk.mail.yahoo.com
*
*   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