The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Duplicates in KR file and Empty values for HV005 after merging.
Re: Duplicates in KR file and Empty values for HV005 after merging. [message #15114 is a reply to message #15092] Tue, 05 June 2018 08:30 Go to previous messageGo to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member

Following is a response from Senior DHS Stata Specialist, Tom Pullum:

I can only reply in terms of Stata. The following Stata program is something I use only for difficult KR/PR merges. It has a lot of redundancy. It includes the sex and age (in months) of the child and the line numbers of the child and the mother. It works on this survey. There will be 244,384 children in the merged file. There will be no cases with missing weights. I hope you can convert to SPSS.

set more off
*set maxvar 10000
use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAKR73FL.DTA", clear

keep caseid v001 v002 v003 v005 v024 b4 b16 hw1
keep if b16>0 & b16<.
gen in_KR=1
gen sex_child=b4
gen age_child=hw1
gen line_number_of_child=b16
gen line_number_of_mother=v003
gen hv001=v001
gen hv002=v002
gen hv024=v024
sort hv024 hv001 hv002 sex_child age_child line_number_of_mother line_number_of_child
*list hv024 hv001 hv002 sex_child age_child line_number_of_mother line_number_of_child if _n<=50, table clean
save e:\DHS\DHS_data\scratch\KRtemp.dta, replace

use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\IAPR73FL.DTA" , clear
keep hhid hvidx hv001 hv002 hv003 hv005 hv024 hv112 hv104 hc1
keep if hc1<.
keep if hv112>0 & hv112<.
gen in_PR=1
gen sex_child=hv104
gen age_child=hc1
gen line_number_of_child=hvidx
gen line_number_of_mother=hv112
sort hv024 hv001 hv002 sex_child age_child line_number_of_mother line_number_of_child
*list hv024 hv001 hv002 sex_child age_child line_number_of_mother line_number_of_child if _n<=50, table clean
merge 1:1 hv024 hv001 hv002 sex_child age_child line_number_of_mother line_number_of_child using e:\DHS\DHS_data\scratch\KRtemp.dta

tab in*,m
keep if in_KR==1 & in_PR==1
drop in*

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Merging HW to IR for Mali DHS IV - Missing HWCASEID
Next Topic: Appending datasets of one country for several years
Goto Forum:
  


Current Time: Thu Nov 28 15:43:03 Coordinated Universal Time 2024