Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: Identifying the nearest observation in a household survey


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: Identifying the nearest observation in a household survey
Date   Thu, 21 Apr 2005 21:55:09 +0100

Richard indicated a health warning. 

Note in addition that this is better read 
as pseudo-code than as Stata code. 

Nick 
n.j.cox@durham.ac.uk 

Richard Palmer-Jones
 
> This won't work if you have more than one child per previous parent.
> You can identify children, then loop back observation by 
> observation till
> you get to a likely parent - though identifying them may be 
> difficult and
> unclear (guardians) - and watch out for child headed 
> households? With a health warning: 

> gen parent = .
> gen child if age < 18
> qui des
> foreach i in 1/r(N) {
> 	if child == 1 {
> 		local j = 1
> 		local parent = 0
> 		while `parent' < 1 {
> 			if age[`i' - `j'] = [condition for parent - your
> business]
> 				parent[`i'] = serial[`i'-`j'] * 100 +
> pernum[`i'-`j']
> 				local parent = 1
> 			}
> 			local ++j
> 		}
> 	}
> }

Scott Merryman replied to Deborah Garvey

> > I want the adult who is listed before the child in the 
> household record,
> > since Census/sociology research shows he/she is most likely 
> to be the
> > parent.
> > 
> > An example:
> > 
> > serial     pernum     nfams     famunit famsize   related   
>            age
> > sex  marital
> > 2411276          1         6           1            1   
> Head/Householder
> > 88   F  widow
> > 2411276          2         6           2            1   Other non-
> > relatives 49   M single
> > 2411276          2         6           3            2   Other non-
> > relatives 49   M married
> > 2411276          3         6           3            2   Other non-
> > relatives  42  F  married
> > 2411276          4         6           4            1   Other non-
> > relatives    6  F  single
> > 2411276          5         6           5            1   Other non-
> > relatives  68  F widow
> > 2411276          6         6           6            1   Other non-
> > relatives  58  M widow
> > 
> > The child in line #4 is most likely the child of #2 and #3. 
>  Can someone
> > help me get started?  I'm running Stata/SE 8.2, Windows, 
> born 1/10/05.
> > 
> 
> Do you mean something like this?
> 
> . l serial relate age sex marital , abb(32) noobs
> 
>   +--------------------------------------------------+
>   |  serial            related   age   sex   marital |
>   |--------------------------------------------------|
>   | 2411276   Head/Householder    88     F     widow |
>   | 2411276              Other    49     M    single |
>   | 2411276              Other    49     M   married |
>   | 2411276              Other    42     F   married |
>   | 2411276              Other     6     F    single |
>   |--------------------------------------------------|
>   | 2411276              Other    68     F     widow |
>   | 2411276              Other    58     M     widow |
>   +--------------------------------------------------+
> 
> . mark child if age <18
> 
> . mark parent_of_child if age>=18 & child[_n+1] == 1
> 
> . l serial  age sex marital child par, abb(32) noobs
> 
>   +---------------------------------------------------------+
>   |  serial   age   sex   marital   child   parent_of_child |
>   |---------------------------------------------------------|
>   | 2411276    88     F     widow       0                 0 |
>   | 2411276    49     M    single       0                 0 |
>   | 2411276    49     M   married       0                 0 |
>   | 2411276    42     F   married       0                 1 |
>   | 2411276     6     F    single       1                 0 |
>   |---------------------------------------------------------|
>   | 2411276    68     F     widow       0                 0 |
>   | 2411276    58     M     widow       0                 0 |
>   +---------------------------------------------------------+
> 

*
*   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