Hi friends,
I have data about parents and their children, it is build like that:
id_parent - parent identifier
birth_year - the birth year of every one of his children
id_child - child identifier
So the number of observation that will get certain value of the variable "id_parent" is the number of children this parent have. Every value of id_child will appear twice - one when he or she connected to his/her father ID and one for his/her mother ID.
Now I want to rank the children according to their year of birth, so I wrote the next code:
The trouble is that in case of twins it might create situation that one twin is ranked 1 for his father and 2 for his mother and vice versa. It is problem for me when I later want to keep only couples that had their first child together.
So I tried the next code:
and I thought it will solve it since it suppose to rank them initially by the birth year and if there are equalizer than by the id_child, but I got an error message that says "birth_yearid_child invalid name", and it made me thought maybe the function rank can use only one variable.
So does it true? and maybe someone can find me way to solve my problem?
Thank you already,
FitzGerald
I have data about parents and their children, it is build like that:
id_parent - parent identifier
birth_year - the birth year of every one of his children
id_child - child identifier
So the number of observation that will get certain value of the variable "id_parent" is the number of children this parent have. Every value of id_child will appear twice - one when he or she connected to his/her father ID and one for his/her mother ID.
Now I want to rank the children according to their year of birth, so I wrote the next code:
Code:
bysort id_parent: egen sibiling_order = rank(birth_year), unique
So I tried the next code:
Code:
bysort id_parent: egen sibiling_order = rank(birth_year id_child), unique
So does it true? and maybe someone can find me way to solve my problem?
Thank you already,
FitzGerald
Comment