Hi,
I face a problem in assigning values of a variable within a group. This is a study about historical human fertility analysis.
The births are grouped by mothers' id. Births of the same mother are in the same group. There is a variable denoting their birth orders.
The births are denoted as sons or daughters. The births are also denoted whether they are dead or not. There is a variable identifying whether a newborn is dead. I want to study the effect of existing births on the likelihood of later births.
The variable of existing births is a categorical variable: 0=surviving children of both sex; 1= only girl alive, no boy; 2= only boy alive, no girl; 3= no surving children of either sex
The following table is an example of the full list:
I wonder how to generate the values of "existing_births". This is a variable based on other three or four variables within a group. I did not figure out how to code it.
Thank you very much for your kind and generous help!
I face a problem in assigning values of a variable within a group. This is a study about historical human fertility analysis.
The births are grouped by mothers' id. Births of the same mother are in the same group. There is a variable denoting their birth orders.
The births are denoted as sons or daughters. The births are also denoted whether they are dead or not. There is a variable identifying whether a newborn is dead. I want to study the effect of existing births on the likelihood of later births.
The variable of existing births is a categorical variable: 0=surviving children of both sex; 1= only girl alive, no boy; 2= only boy alive, no girl; 3= no surving children of either sex
The following table is an example of the full list:
MOTHER_ID | PERSON_ID | boy | girl | birth_order | died | existing_births |
1 | 1 | 1 | 0 | 1 | 0 | 3 |
1 | 2 | 1 | 0 | 2 | 0 | 2 |
2 | 3 | 1 | 0 | 1 | 1 | 3 |
3 | 4 | 0 | 1 | 1 | 1 | 3 |
3 | 5 | 1 | 0 | 2 | 0 | 3 |
3 | 6 | 1 | 0 | 3 | 0 | 2 |
3 | 7 | 0 | 1 | 4 | 0 | 2 |
4 | 8 | 1 | 0 | 1 | 0 | 3 |
4 | 9 | 0 | 1 | 2 | 0 | 2 |
5 | 10 | 1 | 0 | 1 | 0 | 3 |
5 | 11 | 1 | 0 | 2 | 1 | 2 |
5 | 12 | 0 | 1 | 3 | 0 | 2 |
5 | 13 | 0 | 1 | 4 | 0 | 0 |
5 | 14 | 1 | 0 | 5 | 0 | 0 |
6 | 15 | 1 | 0 | 1 | 1 | 3 |
7 | 16 | 0 | 1 | 1 | 0 | 3 |
7 | 17 | 0 | 1 | 2 | 1 | 1 |
7 | 18 | 0 | 1 | 3 | 0 | 1 |
I wonder how to generate the values of "existing_births". This is a variable based on other three or four variables within a group. I did not figure out how to code it.
Thank you very much for your kind and generous help!
Comment