The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Nutrition and Anthropometry » Rate of exclusive breastfeeding in Nigeria (2018 DHS)
Re: Rate of exclusive breastfeeding in Nigeria (2018 DHS) [message #19137 is a reply to message #19093] Sat, 25 April 2020 16:13 Go to previous message
Mlue
Messages: 92
Registered: February 2017
Location: North West
Senior Member
Hello,

Try this code (below). Maybe it will point you in the right direction.

** OPEN THE DATA **.
*** I AM USING Stata DATA - I HAD NOT DOWNLOADED THE SPSS FILES (this code will also work for the SPSS file) ***.
CD "C:\Users\User01\Documents\DHS DATA\NIGERIA_2018\NGKR7ADT".
GET
  STATA FILE='NGKR7AFL.DTA'.
DATASET NAME DataSet1 WINDOW=FRONT.

********************************************.
** GENERATE THE WEIGHT VARIABLE & WEIGHT DATA **.
COMPUTE weight = V005/1000000.

WEIGHT BY weight.

********************************************.
** PREPARE COMPLEX SURVEY VARIABLES **.
COMPUTE psu = V021.
COMPUTE strata = V023.

********************************************.
** RENAME A FEW VARIABLES TO BE USE IN ANALYSIS **.
RENAME VARIABLES (V013 = age) (V149 = education) (V190 = wealth) (V025 = residence) (V024 = region).

********************************************.
SORT CASES CASEID (A).
STRING hhid (A12).
COMPUTE hhid = SUBSTR(caseid,1,12).
VARIABLE LABELS hhid "hhid".
EXECUTE.

********************************************.

** REARRANGE DATA. 
ADD FILES FILE * 
   /KEEP CASEID hhid ALL. 
EXECUTE.

********************************************.
COMPUTE child_age = b19.

RECODE child_age (0 THRU 1 = 1) (2 THRU 3 = 2) (4 THRU 5 = 3) (6 THRU 8 = 4) (9 THRU 11 = 5) 
                             (12 THRU 17 = 6) (18 THRU 23 = 7) (ELSE=SYSMIS) into child_age_grp.
VALUE LABELS child_age_grp 1 "0-1" 2 "2-3" 3"4-5" 4 "6-8" 5 "9-11" 6 "12-17" 7 "18-23".
VARIABLE LABELS child_age_grp 'Age group of child in months'.
EXECUTE.

********************************************.
* KEEP IF CHILD IS UNDER 24 MONTHS OLD AND LIVING WITH MOTHER.
SELECT IF child_age LT 24 & B9 EQ 0.
*SELECT IF B5 EQ 1.

********************************************.
* FIND THE YOUNGEST CHILD LIVING WITH THE MOTHER FOR EACH MOTHER.
SORT CASES BY V001 V002 V003.

AGGREGATE
   /OUTFILE=* MODE=ADDVARIABLES
   /BREAK=V001 V002 V003
   /MINBIDX "MINBIDX"=MIN(BIDX).
EXECUTE.

* NEED TO DROP THOSE THAT ARE BIDX EQ 2 AND MINBIDX EQ 1.
SELECT IF (BIDX LE MINBIDX) .
EXECUTE.

********************************************.
* COMPONENTS OF CHILD FEEDING.

*// Plain water.
COMPUTE PlainW = 0.
   IF (V409 GE 1 & V409 LE 7 = 1) PlainW = 1.
EXECUTE.

*// Non milk .
COMPUTE NonMilk = 0.
   IF (V410 EQ 1 OR V413 EQ 1) NonMilk = 1.
   IF (V412c GE 1 & V412c LE 7) NonMilk = 1.
EXECUTE.

*// Milk .
COMPUTE Milk = 0.
   IF (V411 EQ 1 OR V411A EQ 1 OR V412A EQ 1 OR V414P EQ 1) Milk = 1.
EXECUTE.

*// Currently breastfeeding .
COMPUTE CBreastF=0.
IF (M4 = 95) CBreastF = 1.
VALUE LABELS CBreastF 0"Not breastfeeding" 1"Currently breastfeeding".

*// Ever bottle-fed .
COMPUTE BF=0.
IF (M38 = 1) BF = 1.
VALUE LABELS BF 0"Not bottle-fed" 1"Ever bottle-fed".

*// Complementary food .
COMPUTE Complem = 0.
   IF (V414E EQ 1 OR V414F EQ 1 OR V414G EQ 1 OR V414H EQ 1 OR
        V414I EQ 1 OR V414J EQ 1 OR V414K EQ 1 OR V414L EQ 1 OR
        V414M EQ 1 OR V414N EQ 1 OR V414O EQ 1 OR V414P EQ 1 OR
        V414S EQ 1 OR V414V EQ 1) Complem = 1.
   IF V412A EQ 1 Complem = 1.
EXECUTE.

********************************************.

COMPUTE diet = 7.
   IF (PlainW EQ 0 & NonMilk EQ 0 & Milk EQ 0 & Complem EQ 0) diet = 0.
   IF (PlainW EQ 1 & NonMilk EQ 0 & Milk EQ 0 & Complem EQ 0) diet = 1.
   IF (NonMilk EQ 1 & Milk EQ 0 & Complem EQ 0) diet = 2.
   IF (Milk EQ 1 & Complem EQ 0) diet = 3.
   IF (Milk EQ 0 & Complem EQ 1) diet = 4.
   IF (Milk EQ 1 & Complem EQ 1) diet = 5.
   IF (CBreastF EQ 0) diet = 6.
VARIABLE LABELS diet 'Breastfeeding status - checks'.
EXECUTE.

COMPUTE feeding = 1.
   IF (PlainW EQ 1) feeding = 2.
   IF (NonMilk EQ 1) feeding = 3.
   IF (Milk EQ 1) feeding = 4.
   IF (Complem EQ 1) feeding = 5.
   IF (CBreastF EQ 0) feeding = 0.
VARIABLE LABELS feeding 'Breastfeeding status - final'.
VALUE LABELS feeding 
                                    0"Not breastfeeding" 
                                    1"Exclusively breastfed" 
                                    2"Plain water"
                                    3"Non-milk liquids"
                                    4"Other milk"
                                    5"Complementary foods".
EXECUTE.

********************************************.
* Breastfeeding prevalence.
RECODE feeding (1 THRU 5 = 1) (0 = 0) INTO current_breast.
VALUE LABELS current_breast 0 "Not breastfeeding" 1 "Breastfeeding".
VARIABLE LABELS current_breast 'Currently breastfeeding'.
EXECUTE.

*creating the predominant breastfeeding variable. 
RECODE feeding (1 THRU 3 = 1) (0 4 5 = 0) INTO predom.
VALUE LABELS predom 0 "Not predominant" 1 "Predominant".
VARIABLE LABELS predom 'Predominantly breastfeeding'.
EXECUTE.

** EVER BREASTFED **.

RECODE M4 (94 = 0) (ELSE= 1) INTO EverBF.
VALUE LABELS EverBF 0 "Not ever breastfed" 1 "Ever breastfed".
VARIABLE LABELS EverBF 'Ever breastfed'.
EXECUTE.

********************************************.
** EXCLUSIVE BREASTFEEDING.
RECODE feeding (1 = 1) (ELSE= 0) INTO exclusive_feed.
VALUE LABELS exclusive_feed 0 "Not exclusive" 1 "Exclusive".
VARIABLE LABELS exclusive_feed 'Exclusive breastfeeding'.
EXECUTE.

********************************************.
SELECT IF feeding LE 5.

******************************************************************************************.
** SELECT ONLY CHILDREN AGED LESS THAN 6 MONTHS **.
SELECT IF child_age LT 6.

********************************************.

** CHECK **.
FREQUENCIES VARIABLES= exclusive_feed
  /ORDER=ANALYSIS.

CROSSTABS
  /TABLES= child_age_grp BY exclusive_feed
  /FORMAT=AVALUE TABLES
  /CELLS=ROW
  /COUNT ROUND CELL.

******************************************************************************************.
 
Read Message
Read Message
Previous Topic: Stunting calculation from Height for age standard deviations from median (WHO)
Next Topic: Missing Data on BMI
Goto Forum:
  


Current Time: Wed Jun 19 16:56:32 Coordinated Universal Time 2024