Begin by thinking carefully about what defines a single-parent household and a two-parent household. First, in order to have parents at all a household must have at least one child. Second, a two-parent household must have a spouse, while a single-parent household must not have a spouse. (This assumes that every household has a head, which is the case here but worth checking in real-world data. Real-world data will also include partners that are not spouses.)

If you've been following along, your do file will already have code to create a variable called hasChildren. If not, create it with:

gen child=(age<18)
by household: egen hasChildren=max(child)

Next we need a variable for whether a household has a spouse or not. Recall that spouses have a 2 for rel2head. Thus we can type:

by household: egen hasSpouse=max(rel2head==2)

This command finds the maximum not of a variable, but of the expression rel2head==2. That expression will be 1 (true) for spouses and 0 (false) for everyone else. Thus its maximum value over a household will be 1 if there is a spouse in the household and 0 otherwise.

Now you're ready to identify the single-parent and two-parent households.

gen singleParent=hasChildren & !hasSpouse
gen twoParent=hasChildren & hasSpouse

There's no need for by household: because neither command looks across observations.

With those indicators in hand, you're ready to look at incomes. Again, if you were following along you already have code to create a householdIncome variable, but if not create it with:

by household: egen householdIncome=total(income)

Now you can compare mean household incomes with:

sum householdIncome if singleParent
sum householdIncome if twoParent

Last Revised: 12/17/2015