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.
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.
Comment