Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Keeping specific observations


From   "David Radwin" <dradwin@mprinc.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Keeping specific observations
Date   Fri, 31 Aug 2012 10:02:56 -0700 (PDT)

Maybe

. bysort id: gen v1min = v1[1]
. drop if v1min==.

David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Eleimon Gonis
> Sent: Friday, August 31, 2012 9:56 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: Keeping specific observations
> 
> Hi Afif,
> 
> thanks for your reply, but no, it wouldn't work, because that command
> would also drop the second individual's missing value in 2001, which I
> want to keep.
> What I'm trying to get is that if an individual has at least one non-
> missing value in any of the years (ID=1 and 2 in the example), they
should
> remain, otherwise drop.
> 
> Eleimon
> 
> From: owner-statalist@hsphsun2.harvard.edu [owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Afif Naeem
> [afeef745@hotmail.com]
> Sent: 31 August 2012 17:46
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: Keeping specific observations
> 
> Shouldnt "drop if v1 == . " work?
> 
> Afif
> 
> > From: Eleimon2.Gonis@uwe.ac.uk
> > To: statalist@hsphsun2.harvard.edu
> > Date: Fri, 31 Aug 2012 17:43:47 +0100
> > Subject: st: Keeping specific observations
> >
> > Dear Statalisters,
> >
> > I would appreciate your help with the following conundrum. Assume I
have
> a dataset that looks like this:
> >
> > Year         ID        v1
> > 2000         1          2
> > 2001         1          2
> > 2002         1          3
> > 2000         2          3
> > 2001         2          .
> > 2002         2          3
> > 2000         3          .
> > 2001         3          .
> > 2002         3          .
> >
> > What I want to achieve is to only keep those individuals that appear
> with any non-missing values for v1 for any of the years in the dataset.
> >
> > In other words, I don't think that a command: "keep if v1<." would do,
> because that would also take out the 2001 observation for the second
> individual (ID==2), which I'd like to remain in place.
> >
> > Any ideas are welcome,
> > Eleimon
> >
> > *
> > *   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/
> 
> *
> *   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/
> 
> 
> 
> *
> *   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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index