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 <[email protected]>
To   [email protected]
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 <[email protected]> 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 <[email protected]> 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
> > [email protected]








 
____________________________________________________________________________________
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index