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

st: Re: panel data programming

From   Kit Baum <>
Subject   st: Re: panel data programming
Date   Thu, 24 Apr 2008 08:19:16 -0400

Just treat each (household/mother) as your basic unit of analysis. You should be able to do this with egen's group function, where hhid and momid form a group. Then you can apply the logic you have to 'spread' the mom's educ level across all children in that HH with that mother.


Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

On Apr 24, 2008, at 02:33 , Jeremy wrote:

I am working with a panel data set which has identifiers by household
(hhid) and individual (id).  I am trying to get information about the
mothers education, which is located in the parents row, into
children's row.   I figured out how to do this as long as there is
only one mother in each household.  The problem is there are some
households with more than one mother per household.  "momid" indicates
which id is the mother in the household and is a number between 3 and

hhid   id     edu     momid     (Want mom edu)
  1      1      4            0                  .
  1      2      0            0                   .
  1      3      6            5                  3
  1      4      8            5                  3
  1      5      3            0                  .
  1      6      2            3                  6
  1      7      4            3                  6

My improper and clunky coding. (it works as long as there is only one
mother per household)

bysort hhid: gen check=momid if momid>2 & momid<20
by hhid: egen m=max(check)
by hhid: gen mo=1 if m==id
by hhid: gen medu=mo*edu
by hhid: egen momedu=max(medu)
by hhid: replace momedu=.  if momid<3 | momid>19
drop check m mo medu

How can I program this with more than one mother per household?
*   For searches and help try:

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