The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Ethiopia » Problem with dates in the Ethiopia datasets
Re: Problem with dates in the Ethiopia datasets [message #16602 is a reply to message #16600] Tue, 05 February 2019 10:48 Go to previous messageGo to previous message
kcaglaya@tulane.edu is currently offline  kcaglaya@tulane.edu
Messages: 7
Registered: November 2017
Member
Hi Sandra,

I don't know which software you are using, but here is the Stata code I wrote to convert the dates in 2011 and 2016 Surveys;

*Convert from Ethiopian to Gregorian for 2011 and 2016

foreach y of numlist 2011 2016 {

use "`projectdir'/data/eth_`y'_raw/etkr`y'dt/ETKR`y'FL.dta", clear

*observations with exact birhtday
replace hw16=. if hw16==98 | hw16==99
gen birthday_available=hw16!=.

gen y_gregorian=.
replace y_gregorian=b2+7 if (b1>=9 & hw16>=6) | b1>9
replace y_gregorian=b2+8 if (b1==9 & hw16<6) | b1<9
gen m_gregorian=b1

gen child_birthyear=y_gregorian
gen child_birthmonth=b1
gen child_birthday=hw16

gen child_birthdate_g_days=mdy(child_birthmonth, child_birthday, child_birthyear)
gen child_birthdate_gregorian=child_birthdate_g_days
format child_birthdate_gregorian %td

*convert interview date from Ethiopian to Gregorian Calendar
gen interview_y_gregorian=.
replace interview_y_gregorian=v007+7 if (v006>=9 & v016>=6) | v006>9
replace interview_y_gregorian=v007+8 if (v006==9 & v016<6) | v006<9
gen interview_m_gregorian=v006

gen interview_year=interview_y_gregorian
gen interview_month=v006
gen interview_day=v016

gen interview_date_g_days=mdy(interview_month, interview_day, interview_year)
gen interview_date_gregorian=interview_date_g_days
format interview_date_gregorian %td

tempfile `y'_temp

save "``y'_temp'"

}

Best,

Koray
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Height and Weight Scores (WHO Child Growth Standards) data
Next Topic: prevalence of anemia and associated factors
Goto Forum:
  


Current Time: Fri May 14 05:39:32 Coordinated Universal Time 2021