> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Richard Palmer-Jones
> Sent: Thursday, April 21, 2005 11:44 AM
> To: [email protected]
> Subject: st: RE: RE: Identifying the nearest observation in a household
> survey
>
> This won't work if you have more than one child per previous parent.
I am not sure I understand; the parent is flagged only if the age >= 18, it
has the same serial # (thanks Nick), and the following observation is a
flagged a child.
Suppose we have two households:
. l , ab(32) noobs sepby(ser)
+-----------------------------------------+
| serial related age sex marital |
|-----------------------------------------|
| 2411276 Head 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 |
|-----------------------------------------|
| 1 Head 88 F widow |
| 1 Other 49 M single |
| 1 Other 49 M married |
| 1 Other 42 F married |
| 1 Other 6 F single |
| 1 Other 5 F single |
| 1 Other 4 F single |
| 1 Other 58 M widow |
| 1 Other 20 F single |
| 1 Other 1 F single |
+-----------------------------------------+
. mark child if age <18
. mark parent_of_child if age>=18 & child[_n+1] == 1 & serial ==
serial[_n+1]
. l , ab(32) noobs sepby(ser)
+-------------------------------------------------------------------+
| serial related age sex marital child parent_of_child |
|-------------------------------------------------------------------|
| 2411276 Head 88 F widow 0 0 |
| 2411276 Other 49 M single 0 0 |
| 2411276 Other 49 M married 0 0 |
| 2411276 Other 42 F married 0 1 |
| 2411276 Other 6 F single 1 0 |
| 2411276 Other 68 F widow 0 0 |
| 2411276 Other 58 M widow 0 0 |
|-------------------------------------------------------------------|
| 1 Head 88 F widow 0 0 |
| 1 Other 49 M single 0 0 |
| 1 Other 49 M married 0 0 |
| 1 Other 42 F married 0 1 |
| 1 Other 6 F single 1 0 |
| 1 Other 5 F single 1 0 |
| 1 Other 4 F single 1 0 |
| 1 Other 58 M widow 0 0 |
| 1 Other 20 F single 0 1 |
| 1 Other 1 F single 1 0 |
+-------------------------------------------------------------------+
Scott
> 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
> }
> }
> }
*
* 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/