Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Phil Schumm <pschumm@uchicago.edu> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Drop Observations Satisfying List |
Date | Tue, 10 Sep 2013 20:26:42 -0500 |
On Sep 10, 2013, at 7:54 PM, Lisa Wang <lhwang0925@gmail.com> wrote: > I have a column of dates in one dataset ("A") and my actual analysis in another dataset ("B"). I would like to drop all the observations in "B" which has a date found in dataset "A". > > There are about 750 or so dates in dataset "A". > > I am unsure how to do a drop if/ keep if when the condition could be a whole array of dates. You'll want to do something like this (assuming that your date variable is named "date"): use dataset_b merge 1:1 date using dataset_a, keep(master) nogen which will drop all observations from dataset_b with a date which is found in dataset_a. Note that if the same date may appear multiple times in dataset_b, then you'll need to replace 1:1 with m:1. I'm assuming that date is unique in dataset_a, but since you're only using this as a lookup table, if this is not the case, then you can just make a copy of dataset_a where duplicate dates have been excluded. -- Phil * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/