The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Kenya » KDHS 2014: Table 2.14 School attendance ratios
KDHS 2014: Table 2.14 School attendance ratios [message #28069] Tue, 07 November 2023 12:11 Go to next message
sokiya is currently offline  sokiya
Messages: 80
Registered: May 2017
Location: Nairobi
Senior Member
I am trying to generate Table 2.14 School attendance ratios using the microdata and the code from the DHS GitHub repo as shown below
* open the birth history data to extract date of birth variables needed.
use "KEBR71FL.DTA", clear

* keep only the variables we need
keep v001 v002 v003 b3 b16
* drop if the child in the birth history was not in the household or not alive 
drop if b16==0 | b16==.
* rename key variables for matching 
rename b16  hvidx
rename v001 hv001
rename v002 hv002
* sort on key variables
sort hv001 hv002 hvidx

* if there are some duplicates of line number in household questionnaire, we need to drop the duplicates
gen dup = (hv001 == hv001[_n-1] & hv002 == hv002[_n-1] & hvidx == hvidx[_n-1])
drop if dup==1
drop dup
* re-sort to make sure still sorted
sort hv001 hv002 hvidx

* save a temporary file for merging
tempfile tempBR
save `tempBR'

* use the PR file for household members for the NAR and GAR indicators
use "KEPR71FL.DTA", clear


* merge in the date of birth from the women's birth history for the household member
merge 1:1 hv001 hv002 hvidx using `tempBR'
* there are a few mismatches of line numbers (typically a small number of cases) coming rom the BR file, so let's drop those
drop if _merge==2

* restrict to de facto household members age 5-24, and drop all others
keep if hv103==1 & inrange(hv105,5,24)

* now we calculate the child's age at the start of the school year
* but first we have to specify the month and year of the start of the school year referred to in the survey
* example, for Zimbabwe 2015 survey this was January 2015
global school_start_yr = 2014
global school_start_mo = 1
* also need the age ranges for primary and secondary
global age_prim_min = 6
global age_prim_max = 13
global age_sec_min = 14
global age_sec_max = 17

* produce century month code of start of school year for each state and phase
gen cmcSch = ($school_start_yr - 1900)*12 + $school_start_mo
replace cmcSch = cmcSch+12 if hv008 >= cmcSch+12
* calculate the age at the start of the school year, using the date of birth from the birth history if we have it
gen school_age = int((cmcSch - b3) / 12) if b3 != .
* Impute an age at the beginning of the school year when CMC of birth is unknown
* the random imputation below means that we won't get a perfect match with the report, but it will be close
gen xtemp = hv008 - (hv105 * 12) if b3 == .
gen cmctemp = xtemp - int(uniform()*12) if b3 == .
replace school_age = int((cmcSch - cmctemp) / 12) if b3 == .

* Generate variables for whether the child is in the age group for primary or seconary school
gen prim_age = inrange(school_age,$age_prim_min,$age_prim_max)
gen sec_age  = inrange(school_age,$age_sec_min ,$age_sec_max )

* create the school attendance variables, not restricted by age
gen prim = (hv122 == 1)
gen sec  = (hv122 == 2)

* set sample weight
cap gen wt = hv005/1000000

* For NAR we can use this as just regular variables and can tabulate as follows, but can't do this for GAR as the numerator is not a subset of the denominator
* NAR is just the proportion attending primary/secondary school of children in the correct age range, for de facto children 
gen nar_prim = prim if prim_age == 1
gen nar_sec  = sec  if sec_age  == 1
lab var nar_prim "Primary school net attendance ratio (NAR)"
lab var nar_sec	"Secondary school net attendance ratio (NAR)"

* tabulate primary school attendance 
tab hv104 nar_prim [iw=wt] , row
tab hv025 nar_prim [iw=wt] , row
tab hv270 nar_prim [iw=wt] , row
* tabulate secondary school attendance 
tab hv104 nar_sec [iw=wt] , row
tab hv025 nar_sec [iw=wt] , row
tab hv270 nar_sec [iw=wt] , row

Any help will be appreciated

[Updated on: Tue, 07 November 2023 12:12]

Report message to a moderator

Re: KDHS 2014: Table 2.14 School attendance ratios [message #28075 is a reply to message #28069] Wed, 08 November 2023 08:08 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member

Following is a response from Senior DHS staff member, Tom Pullum:

School attendance ratios are complicated and are not central to the purpose of DHS surveys. I will try to get to this but there will be a delay.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #28143 is a reply to message #28075] Fri, 17 November 2023 11:27 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

I have added a Stata program that is an improvement on the one you were using and on the GitHub program, although it just calculates the net attendance ratios in table 2.14 and just by the child's sex and place of residence. The other parts of table 2.14 should be easy to add. I had written the Stata program now on GitHub several years ago, basically as a translation of a CSPro program originally written by Trevor Croft long ago. The attached version has some simplifications and more comments.

In the original CSPro program for this table for the Kenya 2014 survey, the year and month for eligibility are 2014 and 2 (February), respectively. You were using month 1 (January). It is quite possible that month 1 would have been more consistent with the Kenyan school system, but the program used month 2. In any application of this program, it is essential to adjust those numbers as well as the age ranges for primary and secondary school.

A peculiarity of the DHS procedure (which probably originates with a UN agency) is that a child who is primary age but attending school is counted as not in school. Similarly, a child who is secondary age but attending post-secondary is counted as not in school. I don't think this is fair to kids who manage to skip grades, but that's the procedure.

As stated in the title, the procedure is limited to children who are de facto residents of the household, i.e. were in the household the previous night. This makes some difference.

Unfortunately, the procedure includes a random component that makes it impossible to match the table. The child's cmc of birth is given by b3 if the child is in the BR file, as well as the PR file. For children who are in the PR file but not in the BR tile (and there are many of them), the month of birth is imputed with a uniform random distribution that is consistent with the stated age in years (hv105). That means different results will be given by different random number generators and different seeds. My program just uses "uniform()", and the table in the report uses the CSPro generator. There is no way around this issue. It would be possible to produce a version in which all children were assigned to month 6, or to month 7, which would avoid the random component but would not be as accurate. The bottom line is that you can never match the table on school attendance ratios exactly.



Re: KDHS 2014: Table 2.14 School attendance ratios [message #28144 is a reply to message #28143] Fri, 17 November 2023 12:46 Go to previous messageGo to next message
sokiya is currently offline  sokiya
Messages: 80
Registered: May 2017
Location: Nairobi
Senior Member
Thanks so much for writing the do file and the comprehensive feedback. I sincerely appreciate the assistance.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29118 is a reply to message #28069] Thu, 25 April 2024 10:21 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member
Dear DHS Staff,

I am trying to calculate the school attendance ratios for 2022 KDHS. I am using the code published on the GitHub, but I am unable to match the figures on the final report / statcompiler.
I get 81.9% for primary NAR (instead of 86.2%) and 42.4% (instead of 48.8%).

I have also came across a few posts regarding possible need to recode a few of the school-related variables for this specific survey. Am I right I should wait for a new release of these variables to be able to correctly estimate the primary and secondary school attendance ratios, or should I try and identify what is causing the mismatch? Thank you!
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29125 is a reply to message #29118] Fri, 26 April 2024 07:22 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member

Following is a response from Senior DHS staff member, Tom Pullum:

Hope you can wait a little longer (a month?) and then check back, if nothing has changed. We have been waiting for approval from Kenya before issuing those changes. It is entirely possible that you are correct.

Re: KDHS 2014: Table 2.14 School attendance ratios [message #29349 is a reply to message #29125] Mon, 03 June 2024 11:43 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member

Dear staff,
I was wondering if there was any news about the education-related indicators / data for the 2022 KDHS survey round, and whether changes have been or will be made in the near future.
Many thanks.
Best regards!

Re: KDHS 2014: Table 2.14 School attendance ratios [message #29355 is a reply to message #29349] Tue, 04 June 2024 14:25 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member

Following is a response from Senior DHS staff member, Tom Pullum:

We expect that an updated version of the Kenya 2022 data files will be available on the website within a week or two.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29426 is a reply to message #29355] Mon, 17 June 2024 08:13 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member
Dear Staff, will registered users be notified when changes to the 2022 dataset will be completed and made available online for download?
Thank you!
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29427 is a reply to message #29426] Mon, 17 June 2024 08:16 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member
Yes, all users who downloaded the previous version will be notified when we release the new version. The notification/alert will include a description of changes made in the new version.

[Updated on: Mon, 17 June 2024 08:40]

Report message to a moderator

Re: KDHS 2014: Table 2.14 School attendance ratios [message #29764 is a reply to message #29427] Wed, 31 July 2024 11:10 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member
Dear Staff, I was wondering if there is an expected date for the updated primary and secondary school indicators / data for the latest Kenya round to be released. Many thanks!
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29769 is a reply to message #29764] Wed, 31 July 2024 13:49 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member
We do not have a release date at this time.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29889 is a reply to message #29769] Fri, 16 August 2024 17:06 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member
Dear Staff,
I would like to pick up this discussion.
I used the revised dataset that was released on August 13th. I'm however still unable to generate Table 2.14.

Can you please help.

Many thanks.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29896 is a reply to message #29889] Mon, 19 August 2024 07:41 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member

Following is a response from Senior DHS staff member, Tom Pullum:

Your question seems to be about table 2.14 in the Kenya 2014 survey. The updated files were for the Kenya 2022 survey. In the final report on that survey, table 2.14 has nothing to do with schooling. Can you clarity your question? Is it REALLY about table 2.14 in the 2014 survey?
Re: KDHS 2014: Table 2.14 School attendance ratios [message #29913 is a reply to message #29896] Wed, 21 August 2024 17:32 Go to previous messageGo to next message
geoK is currently offline  geoK
Messages: 56
Registered: May 2014
Senior Member
Dear DHS staff,
My apologies. I was referring to Table 2.12 KDHS 2022. I have posted a question specific to that dataset.

Thank you so much.
Re: KDHS 2014: Table 2.14 School attendance ratios [message #30126 is a reply to message #29913] Sun, 29 September 2024 14:01 Go to previous messageGo to next message
sokiya is currently offline  sokiya
Messages: 80
Registered: May 2017
Location: Nairobi
Senior Member
Dear DHS Team,
I am interested in Gross Attendance Ratios in the same table since I want to have the same estimates at county level to explore trends over time. I am using the attached do file which is a modification of what you shared but the results seems to be a bit off. Is there something I am getting wrong? Maybe the CSPro syntax can be of help in this case. There's a section of the report that states Quote:
Youth are considered to be attending school currently if they attended a formal academic school at any point during the given school year. Note that the NAR and GAR values reported here are not comparable with those from previous DHS surveys due to an improvement in the precision of calculation.
Thanks in advance!
Re: KDHS 2014: Table 2.14 School attendance ratios [message #30128 is a reply to message #30126] Mon, 30 September 2024 11:09 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3202
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

Here is a link to the relevant CSPro file for chapter 2 in the final report on the Kenya 2014 survey (attached). Often there is a difference between the table numbers in the CSPro code in the report, and that happens here. The table that appears as 2.14 in the final report is table 2.13 in the attachment. The relevant lines appear at different places in the file. I recommend that you just search for all the appearances of "2.13".

Let us know if you still have a problem.

  • Attachment: CHAPT2.TXT
    (Size: 96.71KB, Downloaded 20 times)
Re: KDHS 2014: Table 2.14 School attendance ratios [message #30130 is a reply to message #30128] Mon, 30 September 2024 13:15 Go to previous message
sokiya is currently offline  sokiya
Messages: 80
Registered: May 2017
Location: Nairobi
Senior Member
Thanks so much for sharing the CSPro syntax. I sincerely appreciate.
I recall you attributed the difference in how CSPro and Stata generate the random number. The Stata do file that you shared for 2022 estimates were really close hence my believe the 2014 can also be close.
Previous Topic: KDHS 2022: Table 2.12 School attendance ratios
Next Topic: SVYSET
Goto Forum:
  


Current Time: Mon Dec 2 10:35:09 Coordinated Universal Time 2024