define prepare (). SET ERRORS OFF. * select only records if dhi filled. select if not missing(dhi) . * recode negaive dhi into zero if (dhi<0) dhi=0. EXECUTE. compute dhi_log = ln(dhi). EXECUTE. if (missing(dhi_log) & NOT(missing(dhi))) dhi_log=0. EXECUTE. * 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 decilecalc (). *** decile procedure. preserve . set tvars names tnumbers values. dataset declare decileratio. WEIGHT BY hwgt. sort cases by did. split file by did. OMS / select tables / if command = ['Frequencies'] subtypes=['Statistics'] /destination format = sav outfile = 'decileratio' /columns sequence = [l1 r2] . frequencies variables = dhi_log /percentiles = 25 50 75 /format = notable . OMSEND. weights off. restore. match files file = * /table = 'decileratio' /rename (var1 = did) /by did . !enddefine . define topbottom (). weight by wt. COMPUTE iqr=dhi_log_75-dhi_log_25. EXECUTE. * detect upper bound for extreme values COMPUTE upper_bound=dhi_log_75 + (iqr * 3). EXECUTE. COMPUTE lower_bound=dhi_log_25 - (iqr * 3). EXECUTE. * top code income at upper bound for extreme values if dhi>exp(upper_bound) dhi=exp(upper_bound). EXECUTE. * bottom code income at lower bound for extreme values if dhi