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

Re: st: Working with DHS for Ghana Year 2003

From   Evans Jadotte <>
Subject   Re: st: Working with DHS for Ghana Year 2003
Date   Fri, 12 Jun 2009 09:42:39 +0200

Tharshini Thangavelu wrote:
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

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
sort hwhhid hwline

use housemem
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?

/ Tharshini

Hi Tharshini,

Maybe you want to 'append' one file to another if what you need is to add new variables to your master file.


*   For searches and help try:

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