Announcement

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

  • Return how many variables were overwritten (because they had the same name) in a merge?

    If I merge two datasets and two variables in the datasets had the same name, how can I get Stata to tell me how many variables (and which) were overwritten?

  • #2
    If you did not use the update option on your merge command no variables present on the "master" dataset were overwritten with values from the using dataset. This is explained in the documentation of the update option found in
    Code:
    help merge

    Comment


    • #3
      and, to expand on the response by William Lisowski , if you did you the "update" option (or the "replace" option), the value given to the _merge variable provided to you by Stata will give you want you seek

      Comment


      • #4
        As a follow-up question, the _merge==5: does anything get over-written here? The manual states "corresponds to matched observations where at least one overlapping variable had conflicting nonmissing values", but I am not clear on whether there are any changes as a result. Thank you in advance!

        Comment


        • #5
          really depends on what options you used in your command and you did not show us this; if you used "update" but not "replace", then you have different non-missing values in the two files and the one in the master data set is retained; if you used both "update" and "replace", then the value in the using data set "over-writes" the value in the master data set

          Comment


          • #6
            Apologies, I should have indicated that I used 'update' only. Thank you so much for clarifying, Rich!

            Comment

            Working...
            X