define prepare ().
* select only records if dhi filled.
select if dhi ne 0 .
select if not missing(dhi) .
* keep only the head.
select if relation eq 1000 .
* create person weight as hwgt times number of household members.
compute wt = hwgt*nhhmem .
* create child weight as hwgt times number of household members under 18.
compute cwt = hwgt*nhhmem17 .
weight by wt.
!enddefine .
define singmomcalc ().
* set equivalence scale as square root of number of household members.
compute ey = dhi/(nhhmem**0.5).
aggregate outfile = *
mode = addvariables
/ break = did
/ ey_median = median(ey)
/ ey_mean = mean(ey)
/ inc_median = median(dhi)
/ inc_mean = mean(dhi).
*** LIS top and bottomcoding.
if dhi gt (10*inc_median) ey = (10*inc_median)/nhhmem**0.5 .
if ey lt (0.01*ey_mean) ey = 0.01*ey_mean .
compute povline5 = ey_median * 0.5 .
compute poor50 = 0 .
if ey lt povline5 poor50 = 100 .
*** choose the weight corresponding to the target population.
weight by cwt.
***Percentage of Children living in single mother families.
* the definition of single mothers households allows other adults to be present.
compute kidsm = 0 .
if sex eq 2 and hpartner eq 200 and nhhmem17 gt 0 kidsm = 100 .
descriptives kidsm .
* child poverty rate , single mother families.
select if (sex eq 2 and nhhmem17 gt 0 and hpartner eq 200).
variable labels poor50 'child poverty, single mother families'.
descriptives poor50.
!enddefine .
match files file = ccyyp
/ table = ccyyh
/ by hid
/ keep = hid did hwgt pwgt age nhhmem nhhmem17 hpartner dhi relation sex.
prepare .
singmomcalc.