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

re: st: problems with joinby or merge

From   Kit Baum <>
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   |
An Introduction to Stata Programming |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

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