Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: one-to-many merge


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: one-to-many merge
Date   Fri, 2 Dec 2005 21:13:09 -0500

Richard wonders why merge does what it does when you duplicate a merge key in one file. See results from the following.

clear
set obs 3
input sid x
1 10
2 20
3 30
sort sid
tempfile one
save `one'
clear
set obs 4
input sid zip
1 11111
2 22222
3 33333
3 33333
sort sid
tempfile two
save `two'
use `one'
merge sid using `two'
tab _merge
list

It is generally a good idea to use options 'unique', 'uniqmaster', 'uniqusing' when you can assert that merge keys should be unique in one or both files.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index