Dear Stata users,
I am using of Ghana year 2003 DHS and want to merge the data files. I have
selected a number of variables by using the software program SELECT and now want
to merge the files. According to the DHS this is possible but following there
instructions given by the DHS doesn't work. I have searched for merging in stata
and it seems very intuitive but I need id variables that are identical in all
the files which is not the case. In the files that I use they are identified
differently.
Ex. I want to merge the height and weight file with the household member recode
file. I should use HV001 (cluster nr) and HWLINE (Line nr) from the height and
weight file with HHID(cluster nr)and HVIDX (line nr) from the members recode
file to merge with the
household member data.
But there is two id variable for each file and the stata cannot identify when I
type the following command:
use height
su
sort hwhhid hwline
clear
use housemem
su
sort hhid hvidx
merge hhid hvidx using height.
This doesn't work simply because the id variables are not the same. So I have
instead renamed the four id variables and then merged them together.
use height
rename hwhhid clusternr
renamne hwline linenr
use housemem
rename hhid clusternr
rename hvidx linenr
Is this a correct way to do it? And is it correct to sort the two id variables
and merge the data files with the two id variables. Do I need to delete all the
missing values before merging?
Thanks
/ Tharshini