Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Unexpected results with merge with update option


From   Robert Picard <picard@netbox.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Unexpected results with merge with update option
Date   Tue, 13 Apr 2010 20:00:52 -0400

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/


© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index