The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Nutrition and Anthropometry » Exclusive Breastfeeding Variable Lesotho (Creating an Exclusive Breastfeeding Variable)
Re: Exclusive Breastfeeding Variable Lesotho [message #17757 is a reply to message #17436] Wed, 22 May 2019 15:24 Go to previous messageGo to previous message
zelalemth is currently offline  zelalemth
Messages: 4
Registered: August 2018
Location: United States
Member
I used the following SAS code to reproduce results on Pakistan Demographic and Health Survey 2017-18 Table 11.3 Breastfeeding status by age.
However, my results are slightly different from what is reported. I was wondering if I am missing something. Thank you for your help.


LIBNAME A "C:\Users\Desktop\Pakistan\";
DATA WORK.PKKR71FL;
SET A.PKKR71FL;


weight = (V005 / 1000000);
cluster = V021;
strata = V023;

/** CHILD'S AGE IN MONTHS **/
child_age=(V008-B3);

IF child_age < 24;

/** CHILD LIVES WITH MOTHER (RESPONDENT) **/
IF b9 EQ 0;

/* REMOVING SCIENTIFIC NOTATION FROM RESULTS OUTPUT */
PROC TEMPLATE;
EDIT BASE.FREQ.CROSSTABFREQS;
EDIT FREQUENCY;
FORMAT=BEST12.;
END;
END;
RUN;

/** FINDING THE YOUNGEST CHILD USING BIDX **/

PROC SORT DATA=WORK.PKKR71FL;
BY V001 V002 V003;
RUN;

PROC SQL;
TITLE 'MINIMUM BIDX OR YOUNGEST CHILD';
CREATE TABLE A.bidx_query AS
SELECT V001,V002,V003,BIDX,M4,M38, MIN(BIDX) AS MINBIDX format=COMMA16.
FROM WORK.PKKR71FL
GROUP BY V001,V002,V003
ORDER BY V001,V002,V003;
RUN;

/* MERGING */
PROC SORT DATA=A.bidx_query;
BY V001 V002 V003;
RUN;

PROC SORT DATA=WORK.PKKR71FL;
BY V001 V002 V003;
RUN;

/** MERGING/COMBINING THE DATA FILES **/

DATA A.PKKR71FL_MERGED;
MERGE WORK.PKKR71FL (IN=x) A.bidx_query (IN=y);
BY V001 V002 V003;
RUN;

DATA WORK.PKKR71FL_MERGED;
MERGE WORK.PKKR71FL (IN=x) A.bidx_query (IN=y);
BY V001 V002 V003;
RUN;

/*********************************************************** **********************/

/** START HERE **/

DATA WORK.PKKR71FL_ExclBF;
SET WORK.PKKR71FL_MERGED;

IF (BIDX <= MINBIDX);

FORMAT diet$29. feeding$26. exclusive_feed$6. none_breast$6. child_age_grp$5. age_at_birth$8. birth_order$3.;

/** CREATE FEEDING VARIABLES **/
water=0;
liquids=0;
milk=0;
solids=0;
breast=0;
bottle=0;

/** TO DETERMINE IF CHILD IS GIVEN WATER, SUGAR WATER, JUICE, TEA OR OTHER **/
IF V409 IN(1:7) THEN water=1;

/** IF GIVEN OTHER LIQUIDS **/
Array liquids2 {9} $ v409a v410 v410a v412c v413 v413a v413b v413c v413d;

DO a=1 to 9;
IF 1<=liquids2{a}<=7 THEN liquids=1;
End;

/** IF GIVEN POWDER/TINNED milk, FORMULA OR FRESH milk **/
Array milk2 {4} $ v411 v411a v412 v414p;

DO b=1 to 4;
IF 1<=milk2{b}<=7 THEN milk=1;
End;

/** IF STILL BREASTFEEDING **/
IF M4 IN(95) THEN breast=1;

/** IF WAS EVER BOTTLE FED **/
IF M38 IN(1) THEN bottle=1;

/** IF GIVEN ANY SOLID FOOD **/
Array solids2 {26} $ V414A V414B V414C V414D V414E V414F V414G V414H V414I V414J V414K V414L V414M V414N V414O V414P V414Q V414R V414S V414T V414U V414V V414W V414X V414Y V414Z;

DO c=1 to 26;
IF 1<=solids2{c}<=7 THEN solids=1;
IF v412a EQ 1 OR v412b EQ 1 THEN solids=1;
End;

/** FIRST INDICATOR VARIABLE **/
diet=7;
IF water=0 & liquids=0 & milk=0 & solids=0 THEN diet = "0. given only water";
IF water=1 & liquids=0 & milk=0 & solids=0 THEN diet = "1. given only liquids";
IF liquids=1 & milk=0 & solids=0 THEN diet = "2. given only milks";
IF milk=1 & solids=0 THEN diet = "3. given only solids";
IF milk=0 & solids=1 THEN diet = "4. given only milk and solids";
IF milk=1 & solids=1 THEN diet = "5. not still breastfeeding";
IF breast=0 THEN diet = "6. not now being breastfed";

/** EBF **/
ebf=0;
IF diet = "0. given only water" THEN ebf = 1;

/** SECOND INDICATOR VARIABLE (FEEDING) **/
feeds=5;
IF diet="6. not now being breastfed" THEN feeds = 0;
IF diet="0. given only water" THEN feeds = 1;
IF diet="1. given only liquids" THEN feeds = 2;
IF diet="2. given only milks" THEN feeds = 3;
IF diet="3. given only solids" THEN feeds = 4;

IF feeds=0 THEN feeding = "0. Not breastfeeding";
IF feeds=1 THEN feeding = "1. Exclusive breastfeeding";
IF feeds=2 THEN feeding = "2. +Water";
IF feeds=3 THEN feeding = "3. +Liquids";
IF feeds=4 THEN feeding = "4. +Other Milk";
IF feeds=5 THEN feeding = "5. +Solids";
LABEL feeding ="Breastfeeding status";

/** EXCLUSIVE BREASTFEEDING **/
exclusive_feed="0. No";
IF feeds IN(1) THEN exclusive_feed = "1. Yes";
LABEL exclusive_feed ="Exclusive breastfeeding";

/** NOT BREASTFEEDING **/
none_breast="0. No";
IF feeds IN(0) THEN none_breast = "1. Yes";
LABEL none_breast ="Not breastfeeding";

/** CREATING THE PREDOMINANTLY BREASTFEEDING VARIABLE **/
predom=0;
IF feeds IN(1:3) THEN predom = 1;

/** CHILD AGE GROUPS **/
IF child_age in(0:1) THEN child_age_grp = "00-01";
IF child_age in(2:3) THEN child_age_grp = "02-03";
IF child_age in(4:5) THEN child_age_grp = "04-05";
IF child_age in(6:8) THEN child_age_grp = "06-08";
IF child_age in(9:11) THEN child_age_grp = "09-11";
IF child_age in(12:17) THEN child_age_grp = "12-17";
IF child_age in(18:23) THEN child_age_grp = "18-23";

/** MATERNAL AGE AT BIRTH **/
agebirth = int((B3-V011)/12);

IF agebirth <20 THEN age_at_birth ="1. <20";
IF agebirth IN(20:34) THEN age_at_birth ="2. 20-34";
IF agebirth >=35 THEN age_at_birth ="3. 35-49";

/** BIRTH ORDER **/
birth_order1 = bord;

IF B0 IN(2) THEN birth_order1 = bord - 1;
IF B0 IN(3) THEN birth_order1 = bord - 2;

IF birth_order1 IN(1) THEN birth_order ="1";
IF birth_order1 IN(2:3) THEN birth_order ="2-3";
IF birth_order1 IN(4:5) THEN birth_order ="4-5";
IF birth_order1 >=6 THEN birth_order ="6+";

DROP a b c feeds agebirth birth_order1;
RUN;

PROC FREQ DATA=WORK.PKKR71FL_EXCLBF;
WEIGHT WEIGHT;
TITLE "Table 11.3 Breastfeeding status by age";
TABLE child_age_grp * feeding /NOCOL NOFREQ NOPERCENT;
RUN;



PROC FREQ DATA=WORK.PKKR71FL_EXCLBF;
WEIGHT WEIGHT;
TITLE "EXCLUSIVE BREASTFEEDING";
TABLE child_age_grp * exclusive_feed /NOCOL NOFREQ NOPERCENT;
RUN;
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Query regarding child BMI standard deviation
Next Topic: Sampling weights
Goto Forum:
  


Current Time: Thu Jan 2 21:49:11 Coordinated Universal Time 2025