Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • merge based on loose match

    Hi there
    I want to merge two datasets ("A" and "B"). Each dataset contains id variable to identify the person, but in each dataset each person can come up more than once (panel data). One way to match 1:1 would be to match on both id and date, the combination of which uniquely identifies the observations. However, some dates from dataset B that should be identical to the dates in dataset "A" are not always exactly the same (they can be out by 1 day either way). Therefore I would like to merge on id and date where date from dataset B can be -1 or +1 date in dataset A.
    Does anyone know if that sort of merge is possible?
    With thanks

  • #2
    I've not seen anything like this with merge 1:1. This is an exact matching merge. Neither 1:m, m:1, m:m are helpful? It sounds like you need to clean up the date variables or see if any combination of variables is a unique id ("isid")?

    Comment


    • #3
      Using -joinby id-, you could create a dataset of the form
      id DateA DateB
      You could then drop observations where DataA and DateB differ by more than one. Then, you could 1:1 merge the data from
      FileB onto this current data set using id and DateB as the key.

      Comment


      • #4
        You can also use rangejoin (from SSC) to limit the matches to those where the date is +/- 1 day.

        Comment

        Working...
        X