/******************************************************************** hh.do Written by Russell Dimond 10/2002 for Intermediate Stata Class Finds properties of households to demonstrate by: processing. ********************************************************************/ clear capture log close set more off log using hh,text replace use hh bysort hh_id: gen size=_N l gen adult=(age>17) by hh_id: egen adults=sum(adult) l drop adult gen male=(sex=="M") by hh_id: egen hasMale=max(male) l drop male bysort hh_id orderInHH: assert _N==1 bysort *: assert _N==1 log close