The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Nutrition and Anthropometry » Initial breastfeeding codes using SAS Egypt DHS 2014 (what is sas code for initial breastfeeding (Egypt DHS 2014))
Initial breastfeeding codes using SAS Egypt DHS 2014 [message #16629] Thu, 07 February 2019 16:28 Go to next message
Nfadl is currently offline  Nfadl
Messages: 7
Registered: February 2019
Member
I am using Egypt DHS 2014 to analyze the initial breastfeeding practice (child file). Table 12.1 showed that percentage of mothers who started breastfeeding within 1 hour (27.1%). However, my results are not matching with the one in the report (mine is 29.6%). BTW, the table is based on last-born children born in the last 2 years preceding the survey.I would be grateful if you could help me to figure out the problem.
I used the following SAS codes:


options source2;
%include '/folders/myfolders/EDHS2014/EDHS2014/FLAT/EGKR61FL/EGKR61FL .SAS';
LIBNAME a '/folders/myfolders/EDHS2014/EDHS2014/FLAT/EGKR61FL';


data work.demo1;
set a.EGKR61FL;
run;

data demo5;
set work.demo1;

sweight = v005/1000000;


child_age=(V008-B3); * CHILD'S AGE IN MONTHS;
IF child_age < 24 then do; * ONLY CHILDREN AGED LESS THAN TWO YEARS OLD;
if V426 in (101:215) then lastchildintialBF=0; *No (late);
else if V426 in (0,100) then lastchildintialBF=1; *Yes;
else lastchildintialBF=.;
end;

run;



proc surveyfreq data = demo5;
cluster v021 ;*PSU;
strata v023;
weight sweight;
TABLES lastchildintialBF ;
RUN;
Re: Initial breastfeeding codes using SAS Egypt DHS 2014 [message #16645 is a reply to message #16629] Mon, 11 February 2019 03:19 Go to previous message
Mlue
Messages: 92
Registered: February 2017
Location: North West
Senior Member
Hello Nfadl,

Try using the following SAS program. When I ran it, it matched the results in the report.
You only need to set the library (LIBNAME) to "EGYPTDHS" where the KR file is located on your computer and the rest should run.
Good luck.

************************************************************ ***********


LIBNAME EGYPTDHS "\\HO12345678\Users\User1\Documents\EGYPT DHS 2014\EDHS2014_SAS";

DATA EGYPTDHS.EDHS_FEEDING;
	SET EGYPTDHS.EGKR61FL;

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

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

	IF child_age < 24;

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

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

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

PROC SORT DATA=EGYPTDHS.EDHS_FEEDING;
	BY V001 V002 V003;
RUN;

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

DATA EGYPTDHS.EDHS_MERGED;
	MERGE EGYPTDHS.EDHS_FEEDING (IN=x) EGYPTDHS.bidx_query (IN=y);
	BY V001 V002 V003;
RUN;

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

/** START HERE **/

DATA EGYPTDHS.EDHS_BF;
	SET EGYPTDHS.EDHS_MERGED;

	IF (BIDX <= MINBIDX);

	FORMAT feeding$26. place_delivery$18. ever_breastfed$6. predom$6.;

/** 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";


/** CHILD BREASTFED WITHIN ONE HOUR **/
	IF M34 in(0:100)			THEN	WITHIN_HOUR="1. Yes";
	IF M34 not in(0:100)		THEN	WITHIN_HOUR="0. No";

/** CHILD BREASTFED WITHIN ONE DAY **/
	IF M34 in(0:200)			THEN	WITHIN_ONE_DAY="1. Yes";
	IF M34 not in(0:200)		THEN	WITHIN_ONE_DAY="0. No";

/** FOR TABLE 11.2 - PERCENTAGE EVER BREASTFED **/
	IF M4 in(93,95)				THEN	ever_breastfed="1. Yes";
	IF M4 not in(93,95)			THEN	ever_breastfed="0. No";

/** DELIVERY CARE **/
	IF M15 in(21:36)			THEN	place_delivery="1. Health facility";
	IF M15 in(11:12)			THEN	place_delivery="2. At home";
	IF M15 not in(11:12,21:36)	THEN	place_delivery="3. Other/Missing";

RUN;

PROC FREQ DATA=EGYPTDHS.EDHS_BF;
	WEIGHT	WEIGHT;
	TITLE "TABLE 12.1 - %";
	TABLE 	B4 * ever_breastfed				/NOCOL NOFREQ NOPERCENT;
	TABLE 	B4 * WITHIN_HOUR				/NOCOL NOFREQ NOPERCENT;
	TABLE 	B4 * WITHIN_ONE_DAY				/NOCOL NOFREQ NOPERCENT;
	TABLE 	v025 * ever_breastfed			/NOCOL NOFREQ NOPERCENT;
	TABLE 	place_delivery * ever_breastfed	/NOCOL NOFREQ NOPERCENT;
RUN;

Previous Topic: MDD, MMF and MAD in 2005 EDHS
Next Topic: prelacteal feed
Goto Forum:
  


Current Time: Fri Apr 19 13:38:05 Coordinated Universal Time 2024