Statalist


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

st: Panel Data Programing issues with apologies


From   "Jeremy Page" <miahpage@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Panel Data Programing issues with apologies
Date   Thu, 24 Apr 2008 02:10:46 -0400

Dear Statalist,

I tried to post this yesterday, but it didn't post.  My apologies if
it posts later.

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
19

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?

Is this type of question answered by the stata programing manual?  Or
should I wait for the forthcoming book by Kit Baum's titled "An
introduction to Stata programming?"

Thank you in advance.

Jeremy
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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