Announcement

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

  • Merge dataset with connected ID

    Hi!
    I have an issue trying to merge datasets and would really appreciate your help.


    DATA_1
    id id2
    1 1
    1 2
    2 3
    3 4
    DATA_2
    id var
    1 a
    1 b
    1 a
    2 b
    2 c
    3 a
    My wanted outcome is:
    id id2 var
    1 1 a
    1 1 b
    1 1 a
    1 2 a
    1 2 b
    1 2 a
    2 3 b
    2 3 c
    3 4 a

    I have used the code
    merge m:m id using "DATA_2.dta"

    But that doesn't take into account that I want have a single observation per id2 as well as id and hence not working.

    Thank you so much for the help!

    Hanna

  • #2
    Code:
    use DATA_2, clear
    joinby id using DATA_1
    See

    Code:
    help joinby

    Comment


    • #3
      Thank you so much! Worked perfectly

      Comment

      Working...
      X