Hi Austin Nichols,
Thank you so much for your help. It is much better than my code. However, I
don't understand why grandparents of HH head are not associated with parents
of HH head. It seems that they are connected in the sense that we can get
data for (grandparents ) parents' parents of HH head?
Here is the result after running your code:
+---------------------------------------------------------------+
| ID rel06 yrschl06 sex06 sf fe me |
|---------------------------------------------------------------|
| 1 household head 11 1 0 . . |
| 1 spouse of HH head 12 0 0 . . |
| 1 child of HH head 21 1 1 11 12 |
| 1 child of HH head 23 1 1 11 12 |
| 1 child of HH head 7 0 1 11 12 |
| 1 grandchild of HH head 5 0 1 23 7 | <--
sometimes, I get wrong result here, e.g it gets 21 instead of 23, especially
when there are a lot of
unmarried child of HH head before married child & grandchild.
| 1 child of HH head 12 1 2 11 12 |
| 1 grandchild of HH head 3 1 2 12 . |
3 household head 21 1 0 . 6 |
| 3 child of HH head 13 0 1 21 . |
| 3 child of HH head 6 1 1 21 . |
| 3 parent of HH head 6 0 0 . . | <-- it
should be 6 for father, right?
| 3 grandparent of HH head 6 1 . . . |
My code also has this problem, and I don't know how to fix it yet. Do you
think I can add the married variable to specify more conditions such as
grandchild are associated/followed with married couple, but not with
unmarried members?
Thanks you so much for your great help.
Best,
Minh
-------------------------------------------------------------------------