There are many kinds of user-written matching programs depending on the
metric involved and for what purposes: psmatch2, nnmatch, distmatch, etc.
All available from ssc.
A solution similar to the one posted below would use a metric other
than physical distance.
http://www.stata.com/statalist/archive/2009-08/msg01536.html
It's short enough to post it here but it probably will not make it
past the gatekeeper. Joseph can get it from ssc when Kit gets back
from London or he can contact me privately.
-anymatch- will attempt to find a match according to the user-specified
metric of choice. It should handle many types of matching, including the
sibling-matching (which you can do by using the family id as the
metric, which has the distance of 0).
anymatch [varlist], id(idcode) metric(date)
Since we are mapping from one dataset to another, idcode should be missing
(.) if it came from one of the dataset, which would force a mapping from
the non-missing id to the missing id but not the other way around.
Alternative you can do this relatively easily if you -append- the datasets,
tsfill the missing dates, and search up and down for up to 7 rows, which
would represent 7 days.
Roy
> This is identical to finding the nearest hospital to patients, except
> you don't have to calculate distance between pairs of lat/lon
> coordinates, since the distance is measured in days. See e.g.
> http://www.stata.com/statalist/archive/2007-01/msg00098.html
> and recent threads referencing this trick, e.g.
> http://www.stata.com/statalist/archive/2009-07/msg00083.html
>
> On Tue, Sep 8, 2009 at 12:15 PM, Joseph Wagner wrote:
>> I am using Stata ver 8.2 and wish to merge two files each with an idcode
>> and a date. (I know that more recent versions of Stata can handle this
>> more capably but funds are short at this time so I make do with what I
>> have.) None of the dates in using matches exactly with master. I get
>> the following:
_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.windowslive.com/Desktop/PhotoGallery
*
* 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/