*! 1.0.1 15Apr97 (Jeroen Weesie/ICS) STB-43 dm58 program define hhtab version 5.0 * interface with hh hh_is local hnr : char _dta[HH_nr] local sex : char _dta[HH_sex] local idrop : char _dta[HH_idrop] * parse command line local varlist "ex" local if "opt" local in "opt" local options "ANy ALl *" parse "`*'" tempvar t touse * deal with the household selection (-if- and -in-) hh_slct `if' `in' , `any' `all' gen(`touse') * the cases should be sorted on household-number and sex sort `touse' `hnr' `sex' * exclude observations about the wives in -touse- quiet replace `touse' = 0 if `sex'==2 * loop over all variables parse "`varlist'", p(" ") while "`1'" != "" { capt drop _Husband capt drop _Wife * move the _wife score to husbands's record in variable t quiet gen _Husband = `1' if `touse' quiet gen _Wife = `1'[_n+1] if `touse' capt assert (_Husband==_Wife) if `touse' if _rc { local varl : var label `1' if "`varl'" != "" { local varl = "(" + trim("`varl'") + ")" } di _n in gr "Husband x Wife tabulation of `1'" in wh " `varl'" local vall : value label `1' if "`vall'" != "" { label value _Husband `vall' label value _Wife `vall' } tab _Husband _Wife if `touse', `options' } else { di in gr "Note: `1' does not vary within households" tab `1' if `touse', `options' } mac shift } capt drop _Husband capt drop _Wife end