Given the numChildren variable, all you need to do to identify childless households is look for households where the number of children is zero:

gen childless=(numChildren==0)

There's no need to use by because this command doesn't look across observations in any way. You had to look across the observations in the household to construct numChildren, but at this point each observation has its own copy of the result.

Last Revised: 12/22/2009