* user = your-id * password = your-password * package = stata * project = lis ***Variable selection and data preparation*** local ccyy "" // enter here the country-year identifier, e.g. "us19" local hhvars "did hid hwgt nhhmem nhhmem17 hpartner dhi" local pvars "hid sex relation" use `hhvars' using $`ccyy'h, clear * merge sex of household head from person file merge 1:m hid using $`ccyy'p, keepusing(`pvars') nogen keep if relation==1000 * select only records if dhi filled drop if dhi==. ***Bottom and top coding / outlier detection*** * create disposable household income in logs gen dhi_log=log(dhi) * keep negatives and 0 in the overall distribution of non-missing dhi replace dhi_log=0 if dhi_log==. & dhi!=. * detect interquartile range qui sum dhi_log [w=hwgt],de gen iqr=r(p75)-r(p25) * detect upper bound for extreme values gen upper_bound=r(p75) + (iqr * 3) gen lower_bound=r(p25) - (iqr * 3) * top code income at upper bound for extreme values replace dhi=exp(upper_bound) if dhi>exp(upper_bound) * bottom code income at lower bound for extreme values replace dhi=exp(lower_bound) if dhi=r(p50)*.5 & ey!=. ***Children Poverty Rates - Two Parents Family (50%), headcount ratio (proportion poor)*** *the definition of two parent families allows other adults to be present *the two parents may be married or living as married quietly sum pov50 [w=cwt] if hpartner==1 & nhhmem17>0 & nhhmem>2 display "Children Poverty Rates - Two-Parent Families (50%) = " r(mean) ***Children Poverty Rates - Single Mother Family (50%), headcount ratio (proportion poor)*** *the definition of single mothers households allows other adults to be present quietly sum pov50 [w=cwt] if hpartner==0 & sex==2 & nhhmem17>0 display "Children Poverty Rates - Single-Mother Families (50%) = " r(mean) ***Percentage of Children living in Single Mother Family*** gen kidsm=0 replace kidsm=1 if sex==2 & hpartner==0 & nhhmem17>0 quietly sum kidsm [w=cwt] display "% Living in Single-Mother Households = " r(mean)