The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging KR with PR (Merging Nigeria 2018 KR(master) with PR(using))
Merging KR with PR [message #25445] Thu, 20 October 2022 14:56 Go to previous message
kehinde.atoloye@gmail.com is currently offline  kehinde.atoloye@gmail.com
Messages: 3
Registered: October 2022
Member
Country: Nigeria
Survey:2018
Dataset: Child Recode (KR) and Household Member Recode(PR)

I am working on anemia, diarrhea, and malaria in under-5 children in Nigeria. The data on anemia and diarrhea is contained in the KR file while the data on malaria is contained in the PR file(I do not need the fever data in the KR file). The issue is how to merge the "HOUSEHOLD - Malaria: by Household Member" subset of the PR file to the KR file. I have adapted several codes I sourced on this platform but to no avail. I keep getting no observation after merging. I believe I can match the children in the KR file with the "Malaria: by Household Member" section of PR. In the PR file, I tabulated the "child's age in months" against "final result of malaria from blood smear test" and below is a sample of the output as evidence that children's malaria test results are in the PR file. I will appreciate any assistance in this regard to be able to match the children in KR with children in PR. Thanks.


| final result of
child's | malaria from blood
age in | smear test
months | negative positive | Total
-----------+----------------------+----------
6 | 141 31 | 172
7 | 114 34 | 148
8 | 128 23 | 151
9 | 129 21 | 150
10 | 100 21 | 121
11 | 132 16 | 148
12 | 159 24 | 183
13 | 164 39 | 203
14 | 129 25 | 154
15 | 148 35 | 183
16 | 116 32 | 148
17 | 130 28 | 158
18 | 134 24 | 158
19 | 110 21 | 131
20 | 109 32 | 141



Below is the most recent code I adapted:

use "C:\Users\ezpawn\Downloads\NG_2018_DHS_10132022_1330_145124\NGPR7BFL.DTA", clear
keep if  hmhidx==1
gen cluster=hv001
gen hh=hv002
gen caretaker= hml30
sort cluster hh caretaker
save "C:\Users\ezpawn\Downloads\NG_2018_DHS_10132022_1330_145124\NGPR7BFL_Temp.DTA", replace

use "C:\Users\ezpawn\Downloads\NG_2018_DHS_10132022_1330_145124\NGKR7BFL.dta", clear
gen cluster=v001
gen hh=v002
gen caretaker=v003
sort cluster hh caretaker
merge cluster hh caretaker using "C:\Users\ezpawn\Downloads\NG_2018_DHS_10132022_1330_145124\NGPR7BFL_Temp.DTA"

tab _merge

keep if _merge==3
save "C:\Users\ezpawn\Downloads\NG_2018_DHS_10132022_1330_145124\NG_KR_PR_Merged.dta", replace

gen children_per_caretaker=1
collapse(sum) children_per_caretaker, by(cluster hh caretaker)

tab children


 
Read Message
Read Message
Read Message
Previous Topic: Merging Male with Birth data?
Next Topic: Merging Datasets PDHS
Goto Forum:
  


Current Time: Fri Apr 19 15:48:53 Coordinated Universal Time 2024