Hello everyone,
I have households data where parents and children are assigned to each others using pnum (person number) through pfathid and pmothid variables. I want to calculate the age of elder and younger child per each person (not for the whole household) such that for example in caseser 2 (serial of household) the elder child of pnum4 is 63, of both 1 and 2 is 12 and of 3 is 0.
Do you have any idea how i can do this? I tried a loop but i didn't know how to use it to get my desirable answer!
Thank you.
caseser pnum page pfathid pmothid nchild
2 3 12 1 2 0
2 1 63 . 4 1
2 2 52 . . 1
2 4 85 1
4 5 6 1 2 0
4 4 12 1 2 0
4 3 15 1 2 0
4 2 44 3
4 1 48 3
6 4 16 1 2 0
6 3 24 1 2 0
6 1 57 2
6 2 47 2
8 5 16 1 2 0
8 4 16 1 2 0
8 3 24 1 2 0
8 1 57 3
8 2 54 3
I have households data where parents and children are assigned to each others using pnum (person number) through pfathid and pmothid variables. I want to calculate the age of elder and younger child per each person (not for the whole household) such that for example in caseser 2 (serial of household) the elder child of pnum4 is 63, of both 1 and 2 is 12 and of 3 is 0.
Do you have any idea how i can do this? I tried a loop but i didn't know how to use it to get my desirable answer!
Thank you.
caseser pnum page pfathid pmothid nchild
2 3 12 1 2 0
2 1 63 . 4 1
2 2 52 . . 1
2 4 85 1
4 5 6 1 2 0
4 4 12 1 2 0
4 3 15 1 2 0
4 2 44 3
4 1 48 3
6 4 16 1 2 0
6 3 24 1 2 0
6 1 57 2
6 2 47 2
8 5 16 1 2 0
8 4 16 1 2 0
8 3 24 1 2 0
8 1 57 3
8 2 54 3
Comment