Announcement

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

  • Merging_advise

    Hi statalist community, I need some help with merging


    File A has a unique ID
    File B has a unique ID

    The file A and file B have some common unique IDs. Moreover, both files may have some extra unique IDs.

    What I want is, treat file A as master file. Merge to file A from file B, only those IDs that are common to both file A and file B, leaving other information unmerged.


    example

    file A
    Unique_ID varA
    1 100
    2 200
    3 300
    4 400
    5 500

    file B
    Unique_ID varB
    . 1000
    2 2000
    . 3000
    4 4000
    5 5000
    6 6000

    What I want after merging (master file A and using file B)
    Unique_ID varA varB
    1 100 .
    2 200 2000
    3 300 .
    4 400 4000
    5 500 5000
    thanks
    ajay
    Last edited by ajay pasi; 05 Nov 2022, 03:10.

  • #2
    Code:
    merge 1:m Unique_ID using B, keep(1 3)

    Comment


    • #3
      Thanks Øyvind, what does keep(1 3) mean?

      Comment


      • #4
        Øyvind, moreover, file A has repeated IDs as well.

        Comment


        • #5
          I see, try -joinby-

          Comment


          • #6
            Originally posted by ajay pasi View Post
            what does keep(1 3) mean?
            Exactly what it meant here: https://www.statalist.org/forums/for...90#post1687590

            Comment


            • #7
              Thanks Hemanshu.

              Comment


              • #8
                Thanks Øyvind. -joinby- helps. Appreciate that.

                Comment

                Working...
                X