gen byte compage=age - (year==$yr2) gen byte compage2=age -2*(year==$yr2) gen byte comped=educ + (year==$yr1 & mjract==5) /* creates new variable for household relationship to head, newhhrel if same as hhrel for 1 & 2 ( head & spouse ) and non-family individual "49" & for group quarters "51". For others, however, newhhrel aggregates over age & marital status & only own children are distinguished */ gen byte newhhrel=. replace newhhrel=1 if hhrel==1 replace newhhrel=2 if hhrel==2 replace newhhrel=3 if hhrel>=3 & hhrel<=12 replace newhhrel=4 if hhrel>=13 & hhrel<=45 replace newhhrel=5 if hhrel==50 | (hhrel>=46 & hhrel<=48) | (hhrel>=52 & hhrel<=55) replace newhhrel=6 if hhrel==49 replace newhhrel=7 if hhrel==51 capture assert newhhrel~=. if _rc { ${debug}log on count if newhhrel==. local c _result(1) count if hhrel==. local c1 _result(1) noisily display " Note in match $match mis $j there are `c' missing" noisily display "values for newhhrel & `c1' missing values for hhrel" ${debug}log off } exit 0