Home » Topics » Domestic Violence » Code for physical violence in past 12 months (Code for physical violence in past 12 months)
Code for physical violence in past 12 months [message #16740] |
Tue, 26 February 2019 08:49 |
GraceG
Messages: 3 Registered: February 2019
|
Member |
|
|
Hello,
I am trying to generate a variable for 'experienced violence in past 12 months' for women aged 15-49 years using the Kenya 2014 data. I would like to look at the breakdown by education category - these figures are in the DHS report (page 294), but not with the education categories I am looking for.
Is there any STATA code that you can provide to generate this variable? I tried to do so myself but I see it is somewhat complex with different questions asked of married/unmarried women, and I would not like to produce wrong figures.
Thanks very much for your help.
|
|
|
Re: Code for physical violence in past 12 months [message #16754 is a reply to message #16740] |
Wed, 27 February 2019 09:31 |
Mlue
Messages: 92 Registered: February 2017 Location: North West
|
Senior Member |
|
|
Hello GraceG,
Please try the following code. Maybe it may point you in the right direction.
I cannot replicate the category labelled "Often or sometimes". I'm sure one of the DHS experts can direct us in this regard.
clear all
set matsize 800
set maxvar 10000
set mem 1g
cd "C:\Users\Dubile\Documents\KENYA_DHS_2014"
use "KEIR71FL", clear
set more off
********************************************************************************
** WEIGHT VARIABLE
gen weight = d005/1000000
********************************************************************************
** SURVEY SET
gen psu = v021
gen strata = v023
svyset psu [pw = weight], strata(strata)
*svydes
********************************************************************************
// RENAME
rename v013 age
rename v106 education
rename v190 wealth
rename v025 residence
rename v024 region
rename sdist district
** ========================================================================== **
keep if v044==1
** ========================================================================== **
** WOMEN WHO HAVE EVER EXPERIENCED PHYSICAL VIOLENCE SINCE AGE 15**
cap drop anyphysviol
gen anyphysviol = 0 if v044 == 1
ds d105a-d105f d105j d130a d117a
foreach var in `r(varlist)'{
replace anyphysviol = 1 if `var' > 0 & `var' < 5
replace anyphysviol = 1 if d115y==0 | d118y==0
}
*
lab var anyphysviol "Percentage who have ever experienced physical violence since age 15"
lab def anyphysviol 0 "No" 1 "Yes"
lab values anyphysviol anyphysviol
*svy: tab anyphysviol, percent format(%9.1f) miss
*svy: tab anyphysviol, count format(%9.0f) miss
*svy: tab wealth anyphysviol, percent format(%9.1f) miss row
** ========================================================================== **
** FREQUENCY OF PHYSICAL VIOLENCE **
gen violence = 0 if v044==1
foreach dval in 1 2 4 3 {
foreach dvar of var d105a d105b d105c d105d d105e d105f d105j d117a {
replace violence = `dval' if violence == 0 & `dvar' == `dval'
}
}
replace violence = 3 if violence == 0 & d130a == 2
replace violence = 4 if violence == 0 & (d130a == 3 | d130a == 4)
replace violence = 4 if violence == 0 & d115y == 0
replace violence = 5 if violence == 0 & d118y == 0
label define violence 0 "Never" 1 "Often" 2 "Sometimes" ///
3 "Yes, but not in the last 12 months" 4 "Yes, but frequency in last 12 months missing" ///
5 "Yes, but no information when"
label value violence violence
svy: tab violence, percent format(%9.1f) miss
svy: tab wealth violence, percent format(%9.1f) miss row
**********************************
/* CANNOT REPLICATE "Often or sometimes" */
cap drop physicalviolence
recode violence (1=1 "Often") (2=2 "Sometimes") (else=9 "Other"), gen(physicalviolence)
label var physicalviolence "Percentage who have experienced physical violence in the past 12 months"
label value physicalviolence physicalviolence
svy: tab physicalviolence, percent format(%9.1f) miss
svy: tab wealth physicalviolence, percent format(%9.1f) miss row
cap drop violence
** ========================================================================== **
** DROP IF NOT IN SAMPLE **
keep if physicalviolence !=.
** ========================================================================== **
** CHECK **
svy: tab age anyphysviol, percent format(%9.1f) miss row
svy: tab v130 anyphysviol, percent format(%9.1f) miss row
svy: tab residence anyphysviol, percent format(%9.1f) miss row
svy: tab wealth anyphysviol, percent format(%9.1f) miss row
svy: tab age physicalviolence, percent format(%9.1f) miss row
svy: tab v130 physicalviolence, percent format(%9.1f) miss row
svy: tab residence physicalviolence, percent format(%9.1f) miss row
svy: tab wealth physicalviolence, percent format(%9.1f) miss row
** ========================================================================== **
graph bar (percent) [aw=weight], over(anyphysviol, descending) over(wealth) ///
percent stack asyvars bar(5, bfcolor(red*0.8)) ///
bar(4, bfcolor(red*0.3) blcolor(red*0.8)) bar(3, bfcolor(blue*0.2) ///
blcolor(orange*1.2)) bar(2, bfcolor(red*0.7) blcolor(orange*1.2)) ///
bar(1, bcolor(yellow*1.2)) legend(pos(3) col(1)) ysc(r(-5 100)) ///
yla(, ang(h)) blabel(bar, format(%9.1f) pos(center) color(white)) ///
ytitle(%) title(Ever experienced physical violence since age 15) subtitle(Kenya DHS 2014)
exit
|
|
|
|
Goto Forum:
Current Time: Sun Nov 24 21:47:38 Coordinated Universal Time 2024
|