Announcement

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

  • How to Merge Data without Overwriting variables

    Dear all,

    I would like to merge 2 datasets without overwriting the variables that are found in both dataset. I'm using STATA 13. So I created an example to resemble such dataset. In dataset 1, I have id, x1 x2 x3 and x4; and in dataset 2, I have id y1 y2 y3 x1 x2 x3 x4 x5 x6 and x7. I did my code as follows:

    use data1.dta
    merge 1:1 id using data2.dta


    As a result, I only see x1 x2 x3 and x4 once and not twice in the merge dataset (i.e they've been overwritten). However, unlike id which is identical in both dataset, the variables (x1 to x4) have different values in both dataset. For instance, values before a policy change (in data1), and values after policy change (in data2).

    Any possible suggestion, how to deal with this situation is warmly welcome. Thank you.
    Last edited by Owusu Sarpong; 24 Mar 2015, 08:17.

  • #2
    Welcome to Statalist, Owusu! Unfortunately you are in the Forum for making test posts and practicing with the Forum editing software. Post in the General Forum, but before you do, I suggest that you re-read Section 12 of the FAQ.

    Steve
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Alright Mr. Steven. Thank you for the clarification.

      Comment

      Working...
      X