Statalist


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

Re: st: generating houshold size


From   Phil Bardsley <phil_bardsley@unc.edu>
To   statalist@hsphsun2.harvard.edu
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 <phil_bardsley@unc.edu>
Research Programming Services
Carolina Population Center
University of North Carolina
Chapel Hill, NC 27516 USA
919-966-2825
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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