Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Austin Nichols <austinnichols@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Re: Using parent id variables in household data with Stata |
Date | Fri, 23 Nov 2012 17:44:13 +0100 |
DELCLOS GOMEZ-MORAN, CARLOS-ERIC <carloseric.delclos@upf.edu>: Are there mothers of mothers? Do you care if there are? Might do something like this: clear input year country houseid pid momid 2007 0 600 60001 . 2007 0 600 60002 . 2007 0 600 60003 60001 2008 0 600 60001 . 2008 0 600 60002 . 2008 0 600 60003 60001 2008 0 600 60004 60001 end bys year country houseid momid: g N=_N if !mi(momid) g m=min(momid,pid) bys year country houseid m (momid): g n=N[1] if mi(N) list See also: http://www.stata.com/support/faqs/data-management/creating-variables-recording-properties/ http://www.stata.com/statalist/archive/2006-06/msg00323.html On Fri, Nov 23, 2012 at 4:50 PM, DELCLOS GOMEZ-MORAN, CARLOS-ERIC <carloseric.delclos@upf.edu> wrote: > Hello, > > I am trying to count the number of children a mother has in a household > using the mother's id variable from the EU-SILC database. > > Basically, the data looks something like this: > > Year country houseid pid momid > 2007 UK 600 60001 . > 2007 UK 600 60002 . > 2007 UK 600 60003 6001 > 2008 UK 600 60001 . > 2008 UK 600 60002 . > 2008 UK 600 60003 6001 > 2008 UK 600 60004 6001 > > > So what I'd like to do is create a variable with a value for the number of > people (children) in the household who identify the person with that pid > (in this case 60001) as their mother. Is this possible with Stata, and if > so, what is the best way to go about it? * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/