The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » General » Missing records in PR File (SADHS 2016)
Missing records in PR File [message #18315] Thu, 07 November 2019 08:06
Zanele is currently offline  Zanele
Messages: 1
Registered: May 2019
Member
Hi

May you please assist
I am doing analysis on South Africa DHS 2016 whereby I want to derive a variable using the PR file and then merge this variable to the children's recode (KR file) but upon merging, 626 children records are lost/missing [i.e. 626 records are not matched].
Meaning, these kids are not in the PR file but present in the KR and yet I need the 626 to complete my sample size of 3,548. Am i missing something?

Here is the code:

use "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAKR71DT\ZAKR71FL.dta", clear
gen line=b16
sort v001 v002 line

*keep caseid midx v001 v002 v003 v005 bidx line v008 b3 b9 v001 v002 v003 bidx v409* v410* v411* v413* v412* v414* m4 m38 m34 m15 m3* m55* v208 b4

//count = 3,548 or 3,571.9917
gen filetype = 1

save "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAKR71DT\KRtemp.dta", replace

** ============================================================ ============== **

** PREPARE PR FILE FOR MERGE **
clear all
cd "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAPR71DT"
use "ZAPR71FL", clear
*use hhid hvidx hv001 hv002 hv003 hvidx hv005 hv201 hv205 using "IAPR74FL.dta", clear

gen v001=hv001
gen v002=hv002
gen line=hvidx
sort v001 v002 line

*keep hhid hvidx hv001 hv002 hv003 hv005 hv201 hv205 v001 v002 line

//count = 38,850 or 38,012.529
gen filetype = 3

save "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAPR71DT\prtemp.dta", replace

** ============================================================ ============== **
** ============================================================ ============== **

clear all
set matsize 800
set mem 1g
set maxvar 9000
use "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAKR71DT\KRtemp.dta", clear

** MERGE PR FILE AND KR FILE (focusing on the PR file) **
sort v001 v002 line
merge m:m v001 v002 line using "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAPR71DT\prtemp.dta"
rename _merge _merge_PR_KR

/*

. merge m:m v001 v002 line using "C:\Users\ZaneleMt\Desktop\SADHS 2016 DATA\DATASETS\ZAPR71DT\prtemp.dta"
(note: variable v001 was int, now float to accommodate using data's values)
(note: variable v002 was byte, now float to accommodate using data's values)

Result # of obs.
-----------------------------------------
not matched 36,554
from master 626 (_merge==1)
from using 35,928 (_merge==2)

matched 2,922 (_merge==3)
-----------------------------------------


I need that 626 to complete my sample size of 3,548 (2,922+626)
*/

exit

[Updated on: Thu, 07 November 2019 08:06]

Report message to a moderator

 
Read Message
Previous Topic: Spatial analysis
Next Topic: Identifying women's parental information
Goto Forum:
  


Current Time: Thu Mar 28 21:41:57 Coordinated Universal Time 2024