[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: generating houshold size

From   Phil Bardsley <>
Subject   Re: st: generating houshold size
Date   Thu, 28 Aug 2008 09:03:46 -0400

Leonie Fresnius wrote:

What I want to generate is household income weighted by the number of
persons in the household, but I don't have a variable 'household size'
included in my dataset. What I have is information on each houshold
member from a household grid. This means I have a seperate variable
for each household member.

My question is, therefore, if there is a stata command to sum up the
number of household members over these variables?

It sounds like each row/observation in your data is a household. Find a variable that is always present if there is a household member and always missing if there is no household member, such as gender, and use the egen command with a function to count the non-missing values of that variable:

egen hhsize=rownomiss(gender1-gender20)

If instead each observation is a person in the household, then you can use egen with the count function by the household identifier to do the same thing:

bysort hhid: egen hhsize=count(gender)

This second application of egen (using "by") will put the same value of hhsize on each member of the household.

Phil Bardsley <>
Research Programming Services
Carolina Population Center
University of North Carolina
Chapel Hill, NC 27516 USA
* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index