The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Nutrition and Anthropometry » Exclusive breastfeeding (How to complete up with a composite variable)
Exclusive breastfeeding [message #19211] Sun, 10 May 2020 10:34 Go to next message
Nelson Zulu is currently offline  Nelson Zulu
Messages: 2
Registered: May 2020
Member
Hello DHS team,
Am trying to come up with the exclusive breastfeeding variable using the variables m4, m39a, v409 using children dataset Zambia
How can I come up with the exclusive breastfeeding variable using the variables I have listed?
Re: Exclusive breastfeeding [message #19213 is a reply to message #19211] Sun, 10 May 2020 19:11 Go to previous message
Mlue
Messages: 89
Registered: February 2017
Location: North West
Senior Member
Hello Nelson,

On your post, you did not specify some important information such as: the software package you are using, the year of the survey, etc.

I used Stata to produce the following code. The DHS team has written some SPSS and Stata programmes. Please search on GitHub (https://github.com/DHSProgram) for these codes.


********************************************************************************
*************************** EXCLUSIVE BREASTFEEDING ****************************
******************************* ZAMBIA DHS 2018 ********************************
********************************************************************************

clear all
set matsize 800
set maxvar 10000
set mem 1g
cd "C:\Users\...\ZMKR71DT"
use "ZMKR71FL", clear
set more off

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

sort caseid

** WEIGHT VARIABLE
gen weight = v005/1000000

** HHID
gen hhid=substr(caseid,1,12)
sort hhid

** PID
bys hhid: gen pid=_n

** HHSIZE
bys hhid: gen hhsize=_N

** HHTAG
egen hhtag=tag(hhid)

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

** SURVEY SET
gen psu =    v021
//gen strata = v022
gen strata = v023
svyset psu [pw = weight], strata(strata) singleunit(scaled)
*svydes

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

// RENAME

rename v013 age
rename v106 education
rename v190 wealth
rename v025 residence
rename v024 region

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

// GENERATING DEPENDENT VARIABLES

** Child age // if b19 does not exist use: gen b19 = v008-b3
*lookfor b19

capture confirm variable b19
	if _rc {
		gen b19 = v008 - b3
		label variable b19 "current age of child in months (months since birth for dead children)"
}
*

gen child_age=b19

recode child_age (0/1=1 "0-1") (2/3=2 "2-3") (4/5=3 "4-5") (6/8=4 "6-8") ///
(9/11=5 "9-11") (12/17=6 "12-17") (18/23=7 "18-23") (else=.), gen(child_age_grp)

keep if child_age_grp !=.

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

** Child is alive
keep if b5==1

** Child lives with respondent
keep if b9==0

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

* finding the youngest child living with the mother for each mother
bysort v001 v002 v003: egen minbidx=min(bidx)

* keep only children less than 2 years 
keep if child_age<24

* need to drop those that are bidx==2 and minbidx==1
drop if bidx>minbidx

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

gen water=0
gen liquids=0
gen milk=0
gen solids=0
gen breast=0
gen bottle=0

*TO DETERMINE IF CHILD IS GIVEN WATER, SUGAR WATER, JUICE, TEA OR OTHER.
replace water=1 if (v409>=1 & v409<=7)
                                                                  
* IF GIVEN OTHER LIQUIDS 
foreach xvar of varlist v409a v410 v410a v412c v413 v413a-v413d {
replace liquids=1 if `xvar'>=1 & `xvar'<=7
}
*
                                                                                                
* IF GIVEN POWDER/TINNED milk, FORMULA OR FRESH milk
foreach xvar of varlist v411 v411a v412 v414p {
replace milk=1 if `xvar'>=1 & `xvar'<=7
}
*

* IF STILL BREASTFEEDING
replace breast=1 if m4==95 

* IF WAS EVER BOTTLE FED
replace bottle=1 if m38==1 

*IF GIVEN ANY SOLID FOOD
foreach xvar of varlist v414a-v414w m39a {
replace solids=1 if `xvar'>=1 & `xvar'<=7
}
replace solids=1 if v412a==1 | v412b==1

** ========================================================================== **
cap drop diet                
gen diet=7
replace diet=0 if water==0 & liquids==0 & milk==0 & solids==0 
replace diet=1 if water==1 & liquids==0 & milk==0 & solids==0
replace diet=2 if            liquids==1 & milk==0 & solids==0 
replace diet=3 if                         milk==1 & solids==0 
replace diet=4 if                         milk==0 & solids==1 
replace diet=5 if                         milk==1 & solids==1 
replace diet=6 if breast==0 
label define diet 	0"given only water" 1"given only liquids" 2"given only milks" ///
3"given only solids" 4"given only milk and solids" 5"not still breastfeeding" ///
6"not now being breastfed" 7"What"
label var diet "Breastfeeding status1"
label val diet diet

gen ebf=0 
replace ebf=1 if diet==0 

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

** FEEDING
gen feeding=1
replace feeding=2 if water==1
replace feeding=3 if liquids==1
replace feeding=4 if milk==1
replace feeding=5 if solids==1
replace feeding=0 if breast==0
label define feeding 0 "Not breastfeeding" 1 "Exclusive breastfeeding" 2 "+Water" 3 "+Liquids" 4 "+Other Milk" 5 "+Solids"
label val feeding feeding

*creating the predominant breastfeeding variable. 
recode feeding (0 4 5=0) (1/3=1), gen(predom)

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

** DROP IF NOT WITHIN SAMPLE
keep if feeding !=.

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

** Exclusive breastfeeding
recode feeding (1=1 "Exclusive") (else=0 "Not exclusive"), gen(exclusive_feed)
label var exclusive_feed "Breastfeeding and consuming complementary foods"
label val exclusive_feed exclusive_feed

** ========================================================================== **
** CHECK **
svy: tab exclusive_feed, count format(%4.0f) miss
svy: tab child_age_grp exclusive_feed, percent format(%4.1f) row

exit

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

** FOR LESS THAN 6 MONTHS **
keep if inrange(b19,0,5)

svy: tab exclusive_feed, count format(%4.0f) miss
svy: tab child_age_grp exclusive_feed, percent format(%4.1f) row

svy: tab b4 exclusive_feed, percent format(%4.1f) row
svy: tab education exclusive_feed, percent format(%4.1f) row
svy: tab wealth exclusive_feed, percent format(%4.1f) row

exit

Previous Topic: Exclusive breastfeeding
Next Topic: NFHS 3 stratification
Goto Forum:
  


Current Time: Wed May 5 23:09:45 Coordinated Universal Time 2021