DISABILITY - UGANDA DHS 2016 ON SAS [message #17760] |
Thu, 23 May 2019 04:32 |
Mlue
Messages: 92 Registered: February 2017 Location: North West
|
Senior Member |
|
|
Hello,
In case you're trying to derive the Washington Group disability statistics on SAS using the 2016 Uganda DHS, the code below will guide you in the right direction.
/**** IMPORT SPSS DATA TO SAS ****/
PROC IMPORT DATAFILE="\\HO123456789\Users\User1\Documents\UGANDA DHS 2016\UGANDA_2016 _SPSS_DATA\UGPR7AFL"
DBMS=SAV
OUT=WORK.UGANDA_DHS
REPLACE;
RUN;
/** DISABILITY _ UGANDA DHS 2016 ON SAS **/
DATA DISABILITY_UGANDA;
SET WORK.UGANDA_DHS;
weight = (HV005 / 1000000);
psu = HV021;
strata = HV023;
/**** ONLY PERSONS AGED FIVE YEARS AND OLDER ****/
IF HV105 > 4;
/**** FORMAT ****/
FORMAT Agegroup $11. Ungandadisab $21.;
/**** DERIVING DISABILITY ****/
IF SH24 =. OR SH25 =. THEN SEEING = 9;
IF SH24 =1 OR SH25 =1 THEN SEEING = 1;
IF SH24 =2 OR SH25 =2 THEN SEEING = 2;
IF SH24 =3 OR SH25 =3 THEN SEEING = 3;
IF SH24 =4 OR SH25 =4 THEN SEEING = 4;
IF SH24 =8 OR SH25 =8 THEN SEEING = 8;
IF SH27 =. OR SH28 =. THEN HEARING = 9;
IF SH27 =1 OR SH28 =1 THEN HEARING = 1;
IF SH27 =2 OR SH28 =2 THEN HEARING = 2;
IF SH27 =3 OR SH28 =3 THEN HEARING = 3;
IF SH27 =4 OR SH28 =4 THEN HEARING = 4;
IF SH27 =8 OR SH28 =8 THEN HEARING = 8;
IF SH29 =. THEN COMMUNICATE = 9;
IF SH29 =1 THEN COMMUNICATE = 1;
IF SH29 =2 THEN COMMUNICATE = 2;
IF SH29 =3 THEN COMMUNICATE = 3;
IF SH29 =4 THEN COMMUNICATE = 4;
IF SH29 =8 THEN COMMUNICATE = 8;
IF SH30 =. THEN REMEMBERING = 9;
IF SH30 =1 THEN REMEMBERING = 1;
IF SH30 =2 THEN REMEMBERING = 2;
IF SH30 =3 THEN REMEMBERING = 3;
IF SH30 =4 THEN REMEMBERING = 4;
IF SH30 =8 THEN REMEMBERING = 8;
IF SH31 =. THEN WALKING = 9;
IF SH31 =1 THEN WALKING = 1;
IF SH31 =2 THEN WALKING = 2;
IF SH31 =3 THEN WALKING = 3;
IF SH31 =4 THEN WALKING = 4;
IF SH31 =8 THEN WALKING = 8;
IF SH32 =. THEN SELFCARE = 9;
IF SH32 =1 THEN SELFCARE = 1;
IF SH32 =2 THEN SELFCARE = 2;
IF SH32 =3 THEN SELFCARE = 3;
IF SH32 =4 THEN SELFCARE = 4;
IF SH32 =8 THEN SELFCARE = 8;
ARRAY disa2 {6} $ SEEING HEARING COMMUNICATE REMEMBERING WALKING SELFCARE;
disab=0;
sevdisab=0;
undisab1=0;
undisab2=0;
undisab=0;
discount=0;
donotknow=0;
Do k=1 to 6;
if 2<=disa2{k}<=4 then disab=1;
if 3<=disa2{k}<=4 then sevdisab=1;
End;
Do i=1 to 6;
if 3<=disa2{i}<=4 then undisab2=1;
End;
Do j=1 to 6;
if disa2{j}=9 then discount+1;
End;
Do l=1 to 6;
if disa2{l}=8 then donotknow+1;
End;
Do n=1 to 6;
if disa2{n}=4 then undisab1+1;
End;
if undisab1>1 then undisab=1;
if undisab2=1 then undisab=1;
if discount=6 then do;
undisab=9;
disab=9;
sevdisab=9;
end;
if donotknow=6 then do;
undisab=8;
disab=8;
sevdisab=8;
end;
drop k i j l n;
if HV103=1 & undisab NE 9;
IF HV105 IN (0:4) THEN Agegroup="00-04";
IF HV105 IN (5:9) THEN Agegroup="05-09";
IF HV105 IN (10:14) THEN Agegroup="10-14";
IF HV105 IN (15:19) THEN Agegroup="15-19";
IF HV105 IN (20:29) THEN Agegroup="20-29";
IF HV105 IN (30:39) THEN Agegroup="30-39";
IF HV105 IN (40:49) THEN Agegroup="40-49";
IF HV105 IN (50:59) THEN Agegroup="50-59";
IF HV105 IN (60:95) THEN Agegroup="60+";
IF HV105 NOT IN (0:95) THEN Agegroup="DKN/MISSING";
Ungandadisab=undisab;
IF undisab IN (0) THEN Ungandadisab="0. Without disability";
IF undisab IN (1) THEN Ungandadisab="1. With disability";
IF undisab IN (8) THEN Ungandadisab="8. DNK";
IF undisab IN (9) THEN Ungandadisab="9. Unspecified";
RUN;
PROC FREQ DATA=WORK.DISABILITY_UGANDA;
TABLE undisab Ungandadisab;
TABLE Agegroup * Ungandadisab /NOCOL NOFREQ NOPERCENT;
WEIGHT weight;
RUN;
PROC SURVEYFREQ DATA=WORK.DISABILITY_UGANDA;
TABLES Agegroup * undisab /ROW WT;
STRATA strata;
CLUSTER psu;
WEIGHT weight;
RUN;
|
|
|
|
|
Re: DISABILITY - UGANDA DHS 2016 ON SAS [message #18851 is a reply to message #18850] |
Sat, 29 February 2020 19:12 |
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
|
|
|