The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » General » DISABILITY - UGANDA DHS 2016 ON SAS
Re: DISABILITY - UGANDA DHS 2016 ON SAS [message #18851 is a reply to message #18850] Sat, 29 February 2020 19:12 Go to previous message
Mlue
Messages: 92
Registered: February 2017
Location: North West
Senior Member
Hello Chibu,

The following Stata code will point you in the right direction:

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

clear all
set maxvar 9000
set mem 1g
cd "C:\Users\...\NG_2018_DHS_02292020_2134_52565\NGPR7ADT"
use "NGPR7AFL", clear
set more off

** ========================================================================== **
** WEIGHT VARIABLE
gen weight = hv005/1000000

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

** SURVEY SET
gen psu =    hv021
gen strata = hv023

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

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

** PRELIMINARY STUFF

keep if hv105>4

sort hhid hvidx

* Generate "pid"
by hhid: gen pid = _n

* Creating household size
by hhid: generate hhsize=_N

egen hhtag = tag(hhid)

*br hhid hvidx pid hhsize hhtag

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

** CHECK OUT THE VARIABLES
/*
		storage	display	value
variable	name	type	format	label	variable label
						
hdis1		byte	%8.0g	HDIS1	wear glasses or contact lenses
hdis2		byte	%8.0g	HDIS2	have difficulty seeing
hdis3		byte	%8.0g	HDIS3	wear a hearing aid
hdis4		byte	%8.0g	HDIS4	have difficulty hearing
hdis5		byte	%8.0g	HDIS5	have difficulty communicating using usual language
hdis6		byte	%8.0g	HDIS6	have difficulty remembering or concentrating
hdis7		byte	%8.0g	HDIS7	have difficulty walking or climbing steps
hdis8		byte	%8.0g	HDIS8	have difficulty washing all over or dressing
hdis9		byte	%8.0g	HDIS9	highest degree of difficulty for any of the impairments
*/

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

** RENAME VARIABLES
rename hdis2 Seeing
rename hdis4 Hearing
rename hdis5 Communicate
rename hdis6 Remembering
rename hdis7 Walking
rename hdis8 Selfcare

** REPLACE **
replace Seeing 		= 9 if Seeing == .
replace Hearing 	= 9 if Hearing == .
replace Communicate = 9 if Communicate == .
replace Remembering = 9 if Remembering == .
replace Walking 	= 9 if Walking == .
replace Selfcare 	= 9 if Selfcare == .

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

global disa2 "Seeing Hearing Communicate Walking Remembering Selfcare"

gen	disab		=	0
gen	sevdisab	=	0
gen	undisab1	=	0
gen	undisab2	=	0
gen	undisab		=	0
gen	discount	=	0
gen	donotknow	=	0

foreach xvar in $disa2 {
	replace	disab	=	1 if `xvar'>=2 & `xvar'<=4
	replace	sevdisab	=	1 if `xvar'>=3 & `xvar'<=4
}
*

foreach xvar in $disa2 {
	replace	undisab2	=	1 if `xvar'>=3 & `xvar'<=4
}
*

quietly forval q = 1/6 {
	egen temper = anycount($disa2) if `q' !=., values(9)
	replace discount = temper
    drop temper
}
*

quietly forval v = 1/6 {
	egen tempers = anycount($disa2) if `v' !=., values(8)
	replace donotknow = tempers
    drop tempers
}
*

quietly forval s = 1/6 {
	egen new_temp = anycount($disa2) if `s' !=., values(4)
	replace undisab1 = new_temp
    drop new_temp
}
*
replace	undisab	=	1	if	undisab1 > 1
replace	undisab	=	1	if	undisab2 == 1

foreach xvar in discount {
	replace	undisab		=	9 if `xvar' == 6
	replace	disab		=	9 if `xvar' == 6
	replace	sevdisab	=	9 if `xvar' == 6
}
*


foreach xvar in donotknow {
	replace	undisab		=	8 if `xvar' == 6
	replace	disab		=	8 if `xvar' == 6
	replace	sevdisab	=	8 if `xvar' == 6
}
*

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

** DISABILITY INDEX

gen disability_index = undisab
replace disability_index = 0 if undisab == 8
label var disability_index "Washington Group recommended disability index"
label define disability_index 0"Without disability" 1"With disability" 9"DNK/Unspecified"
label val disability_index disability_index

drop disab sevdisab undisab undisab1 undisab2 discount donotknow

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

recode hv105 (0/4=1 "0-4") (5/9=2 "5-9") (10/14=3 "10-14") (15/19=4 "15-19") ///
(20/24=5 "20-24") (25/29=6 "25-29") (30/34=7 "30-34") (35/39=8 "35-39") ///
(40/44=9 "40-44") (45/49=10 "45-49") (50/54=11 "50-54") (55/59=12 "55-59") ///
(60/64=13 "60-64") (65/69=14 "65-69") (70/74=15 "70-74") (75/79=16 "75-79") ///
(80/95=17 "80+") (98=18 "DNK"), gen(Age_5year_Groups)
label var Age_5year_Groups "Age in five-year age groups"
label val Age_5year_Groups Age_5year_Groups

recode hv105 (0/4=1 "0-4") (5/9=2 "5-9") (10/14=3 "10-14") (15/19=4 "15-19") ///
(20/29=5 "20-29") (30/39=6 "30-39") (40/49=7 "40-49") (50/59=8 "50-59") ///
(60/95=9 "60+") (98=10 "DNK"), gen(Agegroup)
label var Agegroup "Age groups"
label val Agegroup Agegroup

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

** DROP IF NOT WITHIN SAMPLE
qui regr disability_index if hv103==1 & (hv105 >=5) & disability_index !=9 [pw=weight]		
drop if e(sample)!=1

** ========================================================================== **
** CHECK **
svy: tab Agegroup disability_index if hv105 >=15 & hv105 <98, percent format(%11.1f) row

svy: tab Agegroup disability_index, percent format(%11.1f) row
svy: tab Agegroup disability_index, count format(%11.0f) miss

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

** DIFFICULTY IN AT LEAST ONE DOMAIN (AGE 15+)

recode hv115 (.=9)
label define hv115 9"Missing"

/* WOMEN */
svy: tab Agegroup disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row
svy: tab hv115 disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row
svy: tab hv025 disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row
svy: tab hv024 disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row
svy: tab hv106 disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row
svy: tab hv270 disability_index if hv105 >=15 & hv104==2, percent format(%11.1f) row

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

/* MEN */
svy: tab Agegroup disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row
svy: tab hv115 disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row
svy: tab hv025 disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row
svy: tab hv024 disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row
svy: tab hv106 disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row
svy: tab hv270 disability_index if hv105 >=15 & hv104==1, percent format(%11.1f) row

** ========================================================================== **
** =================================== END ================================== **
** ========================================================================== **

exit
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Identifying mothers of individuals
Next Topic: Child's day of birth in surveys
Goto Forum:
  


Current Time: Mon Jun 30 11:13:30 Coordinated Universal Time 2025