merging data [message #23949] |
Thu, 20 January 2022 06:17 |
Tedy
Messages: 14 Registered: July 2020
|
Member |
|
|
good evening dear EDS database experts, I am trying to merge the IR file with the CR file, because I am working on parental alcoholism and the health of children under 5 years old. But when I merge, the Z-score of weight for age, weight for height and height for age that I want to use show "no observations" when I tab these variables I don't understand why. I solicit your help please.
|
|
|
Re: merging data [message #23961 is a reply to message #23949] |
Fri, 21 January 2022 11:14 |
Bridgette-DHS
Messages: 3199 Registered: February 2013
|
Senior Member |
|
|
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:
In a separate email you have said that you are working with the 2011 and 2018 Cameroon surveys and want to add the DV variables (prefix d for the mother and md for the father) to the KR file, which has the child outcomes. The following lines show how to do this for the 2018 survey (CM71).
I use an old version of the merge command, but I prefer it. Note that the mother's husband may not be the child's father. Also, in this survey there was subsampling of men.
Most of the mother's IR variables are always on the KR records, but that does not include the DV variables.
* How to add DV variables to the KR file
* The KR file includes the line number of the mother (v003) and the line number of her
* husband (v034), who is usually the father, especially for children age 0-4
* must set up a workspace
cd e:\DHS\DHS_data\scratch
* Prepare mother's data for merge
use "...CMIR71FL.DTA",clear
keep v001 v002 v003 d*
rename v001 cluster
rename v002 hh
rename v003 moline
gen in_IR=1
sort cluster hh moline
save IRtemp.dta, replace
* Prepare father's (usually!) data for merge
use "...CMMR71FL.DTA",clear
keep mv001 mv002 mv003 md*
rename mv001 cluster
rename mv002 hh
rename mv003 faline
gen in_MR=1
sort cluster hh faline
save MRtemp.dta, replace
* Open child's data and merge with mother's data
use "...CMKR71FL.DTA",clear
rename v001 cluster
rename v002 hh
rename v003 moline
rename v034 faline
gen in_KR=1
sort cluster hh moline
merge cluster hh moline using IRtemp.dta
keep if in_KR==1
tab _merge
drop _merge
* Merge with father's data
sort cluster hh faline
merge cluster hh faline using MRtemp.dta
keep if in_KR==1
tab _merge
drop _merge
replace in_MR=0 if in_MR==.
tab in_IR in_MR
*save this file
|
|
|