Home » Topics » Nutrition and Anthropometry » M55 variable missing (Not able to find m55 variable in the data set)
Re: M55 variable missing [message #17609 is a reply to message #17606] |
Fri, 26 April 2019 10:31 |
Mlue
Messages: 92 Registered: February 2017 Location: North West
|
Senior Member |
|
|
Hello,
This will point you in the right direction. The code is supposed to work, but I think I'm missing something.
I'm not getting the exact percentages (maybe one of the DHS experts with assist you).
/*
EXCLUSIVE BREASTFEEDING
National Family Health Survey (NFHS-4)
India 2015-16
*/
clear all
set matsize 800
set maxvar 10000
set mem 1g
cd "C:\Users\MlulekiT\Documents\INDIA DHS"
use "IAKR72FL", clear
set more off
** ========================================================================== **
** WEIGHT VARIABLE
gen weight = v005/1000000
** ========================================================================== **
** SURVEY SET
gen psu = v021
//gen strata = v022
gen strata = v023
svyset psu [pw = weight], strata(strata) singleunit(scaled)
** ========================================================================== **
sort caseid
** 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)
** ========================================================================== **
// 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 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 v410* v413* {
replace liquids=1 if `xvar'>=1 & `xvar'<=7
}
*
cap replace liquids=1 if v412c>=1 & v412c<=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 v414* {
replace solids=1 if `xvar'>=1 & `xvar'<=7
}
replace solids=1 if v412a==1 | v412b==1
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
qui regr feeding if v208 !=0 [pw=weight]
drop if e(sample)!=1
** ========================================================================== **
** CHECK
svy: tab child_age_grp feeding, count format(%4.0f)
svy: tab child_age_grp feeding, percent format(%4.1f) row
** ========================================================================== **
** 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
svy: tab exclusive_feed, count format(%4.0f) miss
svy: tab child_age_grp exclusive_feed, percent format(%4.1f) row
exit
|
|
|
Goto Forum:
Current Time: Thu Dec 26 19:31:22 Coordinated Universal Time 2024
|