The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Child Health » Table 2.11 South Africa DHS 2016 _ Children's living arrangements and orphanhood
Table 2.11 South Africa DHS 2016 _ Children's living arrangements and orphanhood [message #16728] Mon, 25 February 2019 06:18
Mlue
Messages: 92
Registered: February 2017
Location: North West
Senior Member
Hello,

I am trying to match the results contained in Table 2.11 (Children's living arrangements and orphanhood) in the South Africa DHS of 2016.

The code below does not exactly match the results in the abovementioned table. Could someone point me to what I may be missing. Thank you.


clear all
set maxvar 9000
set mem 1g
cd "C:\Users\Dubile\Desktop\SADHS 2016 DATA\DATASETS\ZAPR71DT"
use "ZAPR71FL", clear
set more off
sort hhid

********************************************************************************

** WEIGHT VARIABLE
gen weight = hv005/1000000
gen psu =    hv021
gen strata = hv023

svyset psu [pw = weight], strata(strata) vce(linearized)

********************************************************************************
********************************************************************************
* orphanhood typology
gen orphan_type=.
replace orphan_type=1 if hv111==1 & hv113==1
replace orphan_type=2 if hv111==1 & hv113==0
replace orphan_type=3 if hv111==0 & hv113==1
replace orphan_type=4 if hv111==0 & hv113==0
replace orphan_type=5 if (hv111>1 & hv111<.) | (hv113>1 & hv113<.)

* coresidence typology
* hv112r and hv114r identify parents who are in the household AND are de jure residents 

gen hv112r=0
replace hv112r=1 if hv112>0 & hv112<98

gen hv114r=0
replace hv114r=1 if hv114>0 & hv114<98

cap drop cores_type
gen cores_type=.
replace cores_type=1 if hv112r==1 & hv114r==1
replace cores_type=2 if hv112r==1 & hv114r==0
replace cores_type=3 if hv112r==0 & hv114r==1
replace cores_type=4 if hv112r==0 & hv114r==0

* combined orphanhood and coresidence typology
gen orphan_cores_type=10
replace orphan_cores_type= 1 if orphan_type==1 & cores_type==1 //
replace orphan_cores_type= 2 if orphan_type==1 & cores_type==2 //
replace orphan_cores_type= 3 if orphan_type==2 & cores_type==2
replace orphan_cores_type= 4 if orphan_type==1 & cores_type==3 //
replace orphan_cores_type= 5 if orphan_type==3 & cores_type==3
replace orphan_cores_type= 6 if orphan_type==1 & cores_type==4 //
replace orphan_cores_type= 7 if orphan_type==3 & cores_type==4
replace orphan_cores_type= 8 if orphan_type==2 & cores_type==4
replace orphan_cores_type= 9 if orphan_type==4 & cores_type==4
replace orphan_cores_type=10 if orphan_type==5

#delimit ;
label define orphan_type 1 "Both parents alive" 2 "Mother alive, father dead" 
3 "Father alive, mother dead" 4 "Both parents dead" 5 "Info missing";

label define cores_type 1 "Living with both parents" 2 "With mother, not father" 
3 "With father, not mother" 4 "Living with neither parent";

label define orphan_cores_type 1 "With both parents" 2 "With mother only, father alive" 
3 "With mother only, father dead" 4 "With father only, mother alive" 
5 "With father only, mother dead" 6 "With neither, both alive" 
7 "With neither, only father alive" 8 "With neither, only mother alive" 
9 "With neither, both dead" 10 "Survival info missing"; 
#delimit cr

label values orphan_type orphan_type
label values cores_type cores_type
label values orphan_cores_type orphan_cores_type

* not living with a biological parent {both parents are alive, but lives with neither of them}
gen with_neither_parent=0
replace with_neither_parent=1 if cores_type==4 & orphan_type==1

* one or both parents dead
* note that the allocation of hv111 and hv113 codes other than 0 and 1 is
* slightly different in the table than in "Info missing" above
gen one_or_both_parents_dead=0
replace one_or_both_parents_dead=1 if hv111==0 | hv113==0


*************************************************************************************
** DROP IF NOT WITHIN SAMPLE
keep if orphan_type & hv102==1 & hv105 <18

*************************************************************************************

** CHECK
svy: tab hv270 orphan_cores_type, count format(%4.0f) miss
svy: tab hv270 orphan_cores_type, percent format(%4.1f) miss row

tab hv270 orphan_cores_type [iw=weight], miss row nof

exit
Previous Topic: Haiti treatment sources: more detail on country-specific labels?
Next Topic: Eligibility criteria
Goto Forum:
  


Current Time: Sun Dec 8 01:03:58 Coordinated Universal Time 2024