The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Kenya » Orphan non-orphan school attendance ratio
Orphan non-orphan school attendance ratio [message #17435] Sun, 17 March 2019 11:20 Go to next message
Mercysh is currently offline  Mercysh
Messages: 35
Registered: April 2014
Member
I need help with a code for generating orphan to non-orphan school attendance ratio at regional level using the 2015 Malawi DHS. I have the following code but I am stuck in the process:

gen orphan_age = hv105 >=10 & hv105 <=14

gen school_attendance = hv121 ==2

gen orphaned_m = hv111 ==0 & orphan_age==1
gen orphaned_f = hv113 ==0 & orphan_age==1

gen livingwith_mother = hv112 >= 1 & hv112 <=19
gen livingwith_father = hv114 >= 1 & hv114 <=16

gen nonorphanlivingparent = ((orphaned_m ==0 & livingwith_mother ==1) | (orphaned_f==0 & livingwith_father ==1))

egen Total1 = total((orphaned_m ==1 | orphaned_f ==1) & school_attendance ==1)
egen Total2 = total(nonorphanlivingparent ==1 & school_attendance ==1)

gen ratio = Total1/Total2

egen tag = tag(District)

I do not want to collapse because I have variables at a level different from region


Mercy
Re: Orphan non-orphan school attendance ratio [message #17477 is a reply to message #17435] Thu, 28 March 2019 07:48 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Here's a response from Senior DHS Stata Specialist, Tom Pullum:

Your style for writing code in Stata is very strange to me. You are constructing a set of binary variables, then adding and then dividing. It's possible that this would get you to the right answer but it's not efficient and I don't see how you could incorporate weights. Are you trying to match a table in the report on this survey? If so, which table? Let us know and we will try to help.
Previous Topic: Domestic violence
Next Topic: Ethical approval
Goto Forum:
  


Current Time: Sat Nov 30 05:20:59 Coordinated Universal Time 2024