Dear all,
I´m currently simulating whether individuals/couples get another child in the next period t+1, t+2, ... after they no longer participate in the survey I work with.
So I do have a variable change_child that indicates whether another child is born in t+1.
To be able to that for a couple of years in the future, I always have to update the children information in order to use them as explanatory variables.
For these information I need to assign the birth years of the children to their parents.
My data looks like this:
Therefore, I need kidbirth`y' to take the value of the year t if change_child[_n-1]==1.
The problem is that of course every individual has a certain number of children (n_kids) already, so that the `y' of variable kidbirth`y' (that now should contain the birth year t) has to be n_kids+1.
So for example if a individual has already 2 kids (see example ID 10) and change_child is 1 in period 2002, kidbirth03 has to contain the year 2003.
Can maybe someone help me with the code, since I´ve tried multiple different ways but nothing really worked so far.
Thank you in advance.
I´m currently simulating whether individuals/couples get another child in the next period t+1, t+2, ... after they no longer participate in the survey I work with.
So I do have a variable change_child that indicates whether another child is born in t+1.
To be able to that for a couple of years in the future, I always have to update the children information in order to use them as explanatory variables.
For these information I need to assign the birth years of the children to their parents.
My data looks like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id int year float number_kids int(kidbirth01 kidbirth02 kidbirth03) float change_kid 10 2000 2 1990 1992 -2 0 10 2001 2 1990 1992 -2 0 10 2002 2 1990 1992 -2 1 10 2003 3 1990 1992 . . 13 2000 0 -2 -2 -2 1 13 2001 1 2001 -2 -2 0 13 2002 1 2001 -2 -2 1 13 2003 2 2001 . . . 13 2004 . . . . .
The problem is that of course every individual has a certain number of children (n_kids) already, so that the `y' of variable kidbirth`y' (that now should contain the birth year t) has to be n_kids+1.
So for example if a individual has already 2 kids (see example ID 10) and change_child is 1 in period 2002, kidbirth03 has to contain the year 2003.
Can maybe someone help me with the code, since I´ve tried multiple different ways but nothing really worked so far.
Thank you in advance.
Comment