Quantcast

Unexpected results with merge with update option

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unexpected results with merge with update option

Robert Picard
I rarely use the update option with the merge command and this time I
got an unexpected result. Below is an example of a 1 to many merge
with the variable x1 being missing in the master. I was expecting that
merged records would take the value of x1 from the using dataset but
that is not the case for id == 2. Does anyone understand what is
happening?

Robert

*--------------------------- begin example -----------------------
version 11

clear
input id x1 seq
1 .  1
1 22 2
1 33 3
1 44 4
2 11 1
2 .  2
2 33 3
2 44 4
end

tempfile u
save "`u'"

clear
input id x1
1 .
2 .
end

merge 1:m id using "`u'", update

sort id seq
list , noobs sepby(id)
*--------------------- end example --------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Loading...