Dear Stata list
My data has the following format:
I.e. the data set consists of households (householdID) with people in them (personID). People within a household are numbered consecutively (personinHHID), and a variable (personsfatherID) tells me that within-household ID of their father (if known). How can I create a data set that gives me a person's father's person ID, i.e. make the data set look like this:
Thanks for your consideration
KS
My data has the following format:
Code:
clear input householdID personID personinHHID personsfatherID 1001 5001 1 . 1001 5002 2 . 1002 5003 1 . 1002 5004 2 . 1002 5005 3 1 1003 5006 1 . 1003 5007 2 . end list, sepby(householdID) abbrev(20) +---------------------------------------------------------+ | householdID personID personinHHID personsfatherID | |---------------------------------------------------------| 1. | 1001 5001 1 . | 2. | 1001 5002 2 . | |---------------------------------------------------------| 3. | 1002 5003 1 . | 4. | 1002 5004 2 . | 5. | 1002 5005 3 1 | |---------------------------------------------------------| 6. | 1003 5006 1 . | 7. | 1003 5007 2 . | +---------------------------------------------------------+
Code:
+-----------------------------------+ | householdID personID fatherID | |-----------------------------------| 1. | 1001 5001 . | 2. | 1001 5002 . | |-----------------------------------| 3. | 1002 5003 . | 4. | 1002 5004 . | 5. | 1002 5005 5003 | |-----------------------------------| 6. | 1003 5006 . | 7. | 1003 5007 . | +-----------------------------------+
KS
Comment