Statalist The Stata Listserver


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

Re: st: keeping an inventory of dropped observations


From   Friedrich Huebler <huebler@rocketmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: keeping an inventory of dropped observations
Date   Fri, 30 Mar 2007 08:13:54 -0700 (PDT)

drop if mark_for_drop > 0

Also, in the first -label define- command, the -modify- option is not
needed.

Friedrich

--- Friedrich Huebler <huebler@rocketmail.com> wrote:

> Michael,
> 
> You could save all dropped observations in a separate dataset and
> identify the reasons for dropping them with value labels.
> 
> gen mark_for_drop=0
> replace mark_for_drop=1 if eodlymph==99
> lab def reason_for_drop 1 "missing lymph", modify
> replace mark_for_drop=2 if xyz==99
> lab def reason_for_drop 2 "missing xyz", modify
> ...
> lab val mark_for_drop reason_for_drop
> preserve
> keep if mark_for_drop > 0
> save dropped.dta
> tab mark_for_drop
> restore
> drop if if mark_for_drop > 0
> save clean.dta
> 
> Friedrich
> 
> --- Michael McCulloch <mm@pinest.org> wrote:
> > Hello,
> > While cleaning a dataset, I'm periodically dropping observations
> > that 
> > meet certain criteria, for example:
> > drop if eodlymph==99
> > 
> > Since this occurs very often within a long do-file, I'd like to
> > keep 
> > an inventory of dropped observations & my reason for doing so.
> > Aside 
> > from manually searching through my log file, is there a more
> > elegant 
> > way than what I suggest below, to do this?
> > 
> > For example:
> > gen mark_for_drop=0
> > gen reason_for_drop=.
> > replace mark_for_drop=1 if eodlymph==99
> > replace reason_for_drop="missing lymph" if eodlymph==99
> > ...
> > drop if eodlymph==99
> > ...
> > tab mark_for_drop reason_for_drop if reason_for_drop==1
> > 
> > 
> > Many thanks,
> > Michael
> > 
> > 
> > 
> > -- 
> > 
> > Michael McCulloch, LAc, MPH
> > Research Director
> > Pine Street Foundation
> > 124 Pine St
> > San Anselmo, CA 94960-2674
> > Tel:	(415) 407-1357
> > Fax:	(415) 485-1065
> > mcculloch@pinestreetfoundation.org








 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index