Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Richard Goldstein <richgold@ix.netcom.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: merge within a range |
Date | Fri, 17 Sep 2010 08:44:53 -0400 |
thank you! On 9/16/10 5:51 PM, Phil Schumm wrote: > On Sep 16, 2010, at 3:55 PM, Richard Goldstein wrote: >> I have the following merge problem. In one data set I have a start >> date and and end date (and, of course, several other variables); in >> another data set I have a particular date. I want to merge the two >> data sets with a match occurring if the "particular" date in data set >> 2 is between (or equal) to the startdate/enddate in data set 1. >> >> An obvious kludge is to expand the first data set and fill-in the >> dates to be consecutive. If possible, however, I prefer not to do >> this and am looking for any suggestions. > > > Merge by all of the other variables first, and then just drop the > resulting observations that don't meet your condition (i.e., for which > the date is not between your start and end). If the other variables > together do not uniquely identify the observations in either file, > you'll need to use -joinby- instead of -merge-. > > > -- Phil * * 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/