define prepare ().
* select only records if dhi filled.
select if dhi ne 0 .
select if not missing(dhi) .
* 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 twoparcalc ().
* 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.
* child poverty rate , two parent families.
select if (nhhmem gt 2 and nhhmem17 gt 0 and hpartner eq 1).
variable labels poor50 'child poverty, two parent families'.
descriptives poor50.
!enddefine .
get file = ccyyh /keep = hid did hwgt nhhmem nhhmem17 hpartner dhi.
prepare .
twoparcalc.