The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Height and Weight Files
Height and Weight Files [message #3282] Mon, 17 November 2014 18:00 Go to next message
rejone4@emory.edu is currently offline  rejone4@emory.edu
Messages: 8
Registered: November 2014
Location: United States
Member
For older DHS surveys without the hw73 variables to make zscores for kids anthropometric measurements I know there is a separate data file that has been created called Height and Weight Scores. Is there anyway to merge this type of file with the children's recode variable to be able to differentiate weight status by different ages?
Re: Height and Weight Files [message #3283 is a reply to message #3282] Mon, 17 November 2014 18:10 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 787
Registered: January 2013
Senior Member
Yes - see post #3219 for an example.
Re: Height and Weight Files [message #3305 is a reply to message #3283] Wed, 19 November 2014 14:36 Go to previous messageGo to next message
rejone4@emory.edu is currently offline  rejone4@emory.edu
Messages: 8
Registered: November 2014
Location: United States
Member
thanks that worked well for most datasets. However there are a few HW files that have hwhhid as the variable for case identification.

For example, Armenia 2005 has this type of setup. When I used the following code:

*rename variables and sort data for merging
ren hwhhid caseid
ren hwline midx
sort caseid midx
save "AMHW01_temp.dta", replace


*sort the children's recode data and then merge
use "H:\Thesis\Armenia_2010\Armenia_2005(V)\AMKR42FL.dta", clear
sort caseid midx
merge 1:1 caseid midx using "H:\Thesis\Armenia_2010\Armenia_2005(V)\AMHW01_temp.dta"


It did not match the data anymore. Is there something that has to be done differently with these files?

Re: Height and Weight Files [message #3310 is a reply to message #3282] Wed, 19 November 2014 23:00 Go to previous messageGo to next message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 787
Registered: January 2013
Senior Member
First, I think you are using the wrong files here. The files for Armenia 2005 are AMKR54FL.dat and AMHW52FL.dta, not AMKR42FL.dat and AMHW01FL.dta.

Second, though, later DHS surveys collected the anthropometry data for all children living in the household, as part of the household questionnaire, rather than just children of interviewed women. For that reason the dataset includes hwhhid which is the ID of the household questionnaire. These datasets are principally designed to link with the PR datasets, and analyses in the survey reports are produced from the data in the PR files, not the KR files for these surveys.

If you want to link to the KR files and just use the data for children of interviewed women, then the following is the approach to use:
use "AMKR54FL.dta"
* Create the household ID by dropping the 3 d character line number from caseid
gen hwhhid = substr(caseid,1,length(caseid)-3)
* Make a copy of the household line number (could use rename instead)
clonevar hwline = b16
* Sort on the household ID and the line number from the household schedule
sort hwhhid hwline
* Merge the data
merge m:1 hwhhid hwline using "AMHW52FL.dta"

Note that this uses a many to one merge because b16 can be 0 (if child is not a member of the household) or b16 can be missing (if the child is dead), and more than one child in the household can have these codes. A 1:1 merge will fail because of potential duplicate values of 0 or missing. Alternatively drop if hwline == 0 or hwline == . to avoid the risk of duplicates and then use 1:1 merge.

The following link is also useful for general information on merging datasets: http://www.dhsprogram.com/data/Merging-Datasets.cfm
Re: Height and Weight Files [message #3589 is a reply to message #3310] Wed, 14 January 2015 13:28 Go to previous messageGo to next message
arenaud is currently offline  arenaud
Messages: 1
Registered: January 2015
Location: Canada
Member
Hello,

Could you recommend a similar code for merging the Height-Weight file with the KR file in SPSS?

Thanks in advance.
Re: Height and Weight Files [message #3594 is a reply to message #3589] Wed, 14 January 2015 15:48 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3017
Registered: February 2013
Senior Member
Please search the forum for sample codes, merging datasets in SPSS.
Previous Topic: Correct numbers for merging the household and individual files of the 2001 DHS Nepal
Next Topic: Merging Household+Female+Male files
Goto Forum:
  


Current Time: Fri Mar 29 08:24:48 Coordinated Universal Time 2024