Suppose my data has 2 observations per household and is organized as:
household_id wage of person1 wage of person2
1 3 .
1 5 .
2 6 .
2 7 .
I would like Stata to, whenever the wage of person 2 is missing, to
substitute into it the SECOND observation of the wage of person 1
within that household. So I would want the data to look like:
household id wage of person1 wage of person2
1 3 5
1 5 5
2 6 7
2 7 7
bysort household_id: replace wage2 = wage1[2] if wage2 == .