Statalist


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

re: st: problems with joinby or merge


From   Kit Baum <[email protected]>
To   [email protected]
Subject   re: st: problems with joinby or merge
Date   Tue, 12 May 2009 06:40:32 -0400

<>	
Gaby said

Indeed my Governorate variable had differnt values in each dataset. I have corrected them and it seems Ok now.

Indeed if I would have looked carfully at the _merge variable I wouldn't have spent hours figuring out what was the problem.

I have typed: merge Governorate using dataset2, nokeep


As I recommended, careful examination of the _merge variable is always a good idea. I personally would not use the nokeep option. You can always

drop if _merge == 2
to achieve the same thing after checking that you're not dropping something you shouldn't.

I strongly suggest you use the uniqusing option (as discussed in IMEUS and ISP) when merging an area-level dataset onto an individual-level dataset. Generally it is a good idea to use unique, uniqmaster or uniqusing as appropriate whenever merging to guard against coding errors. So I would use

merge Governorate using dataset2, uniqusing
tab _merge

(after ensuring that _merge is showing what it should)

drop if _merge < 3
drop _merge

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index