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)
Exclusive Breastfeeding Variable Lesotho [message #17436] Sun, 17 March 2019 14:47 Go to next message
LisaSh is currently offline  LisaSh
Messages: 1
Registered: April 2018
Location: Baltimore, MD
Member
I created an exclusive breastfeeding variable using the 2014 Lesotho data, but my exclusive breastfeeding rate does not match the rate in the Final Report.

Does anyone have any ideas on where the error in my SAS code is? The rate I am coming up with is 3.77% which is much lower than the rate in the report.


data babies;
set dhs.lsbr71fl;
age = v008 - b3; /*v008 is century month code of interview; b3 is century month code for dob of child */


if age <= 6 and b5 = 1 and b9 = 0;
/*subset down to living children ages 12 mos and younger living with the mother.
b5 is whether child is alive or dead at time of interview
b9 is person baby lives with and 0 is the mom*/

*compute weights;
weight = v005/1000000;

ClusterMerge=V001;
LineMerge=V003;
HHMerge=V002;
run;

proc freq data=babies order= freq; table caseid/list missing out=freq_out; run;
data twins; set freq_out;
where count=2;
run;

proc sort data=babies; by caseid; run;
proc sort data =twins ; by caseid; run;
data babies_no_twins;
merge twins (in=a) dhs.women_dset_recode(in=b) babies;
by caseid;
if b=1 and a=0;
run;

**********************************;
* Feeding ;
**********************************;

data feeding(drop = i j);
set babies_no_twins/*babies_nodupped*/;

water = 0;
liquids = 0;
milk = 0;
solids = 0;
breast = 0;

*water;
if v409 = 1 then water = 1;

*liquids;
array liqs(*) v409a v410 v410a v412c v413:;
do i = 1 to dim(liqs);
if liqs(i) = 1 then liquids = 1;
end;

*milk;
if v411 = 1 or v411a = 1 or v412 = 1 then milk = 1;

*solids;
array sols (*) v412a v412b v414:;
do j = 1 to dim(sols);
if sols(j) = 1 then solids = 1;
end;

*still breastfeeding;
if m4 = 95 then breast = 1;

*Create hierarchy of FEEDING;
feeding = 1; *feeding starts at 1, excl. b.f. for all babies;
if water = 1 then feeding = 2; *change from 1 to 2 if any water;
if liquids = 1 then feeding = 3; *change from 1 to 3 if any other liquids;
if milk = 1 then feeding = 4; *change to 4 if any milk given;
if solids = 1 then feeding = 5; *change to 5 if any solids;
if breast = 0 then feeding = 0; *change to zero if NOT still breastfeeding;

run;

proc format;
value feeding
0 = "Not breastfeeding"
1 = "Exclusive breastfeeding"
2 = "+Water"
3 = "+Liquids"
4 = "+Other Milk"
5 = "+Solids"
;
run;
data dhs.feeding_cats;
set feeding;

if feeding = 1 then bf = 1;
else bf = 0;
run;

proc freq data=dhs.feeding_cats; table bf; run;
Re: Exclusive Breastfeeding Variable Lesotho [message #17448 is a reply to message #17436] Wed, 20 March 2019 07:28 Go to previous messageGo to next message
Dr_Tsawe
Messages: 76
Registered: February 2017
Location: Cape Town
Senior Member
Hello Yelizaveta,

This SAS code may point you in the right direction.


LIBNAME A "\\H123456789\Users\User1\Documents\Lesotho DHS 2014";

DATA WORK.LESOTHO;
	SET A.LSKR71FL;

	weight = (V005 / 1000000);
	psu    = 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.LESOTHO;
	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.LESOTHO
		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.LESOTHO;
	BY V001 V002 V003;
RUN;

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

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

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

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

/** START HERE **/

DATA WORK.LESOTHO14_ExclBF;
	SET WORK.LESOTHO14_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;


If you're only interested in children aged less than six months, then change this statement "IF child_age < 24;" to "IF child_age LT 6;"

LIBNAME A "\\H123456789\Users\User1\Documents\Lesotho DHS 2014";

DATA WORK.LESOTHO;
	SET A.LSKR71FL;

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

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

	*IF child_age < 24;
	IF child_age LT 6;

/** 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;
Re: Exclusive Breastfeeding Variable Lesotho [message #17757 is a reply to message #17436] Wed, 22 May 2019 15:24 Go to previous messageGo to next message
zelalemth is currently offline  zelalemth
Messages: 3
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;
Re: Exclusive Breastfeeding Variable Lesotho [message #17761 is a reply to message #17757] Thu, 23 May 2019 05:08 Go to previous messageGo to next message
Dr_Tsawe
Messages: 76
Registered: February 2017
Location: Cape Town
Senior Member
Hello Zelalem,

The issue is small. Instead of computing child age from (v008-b3), just use b19. You can read more on b19 from the DHS website.
The code below will work to reproduce table 11.3.


LIBNAME A "\\HO123456789\Users\User1\Documents\PAKISTAN 2017-18 DHS\PK_2017-18_DHS_SAS\PKKR71SD";

DATA WORK.PAKISTAN;
	SET A.PKKR71FL;

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

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

	IF child_age < 24;
	*IF child_age LT 6;

/** 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.PAKISTAN;
	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.PAKISTAN
		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.PAKISTAN;
	BY V001 V002 V003;
RUN;

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

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

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

/** START HERE **/

DATA WORK.PAKISTAN18_ExclBF;
	SET WORK.PAKISTAN18_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.PAKISTAN18_EXCLBF;
	WEIGHT	WEIGHT;
	TITLE "Table 11.3 Breastfeeding status by age";
	TABLE child_age_grp * feeding 			/NOCOL NOFREQ NOPERCENT;
	TABLE child_age_grp * exclusive_feed	/NOCOL NOFREQ NOPERCENT;
RUN;
Re: Exclusive Breastfeeding Variable Lesotho [message #17768 is a reply to message #17757] Thu, 23 May 2019 12:33 Go to previous message
zelalemth is currently offline  zelalemth
Messages: 3
Registered: August 2018
Location: United States
Member
Thank you! This works perfectly.
Previous Topic: Query regarding child BMI standard deviation
Next Topic: Sampling weights
Goto Forum:
  


Current Time: Sun Sep 15 10:49:21 Eastern Daylight Time 2019