Good afternoon, I have a problem in constructing my dataset on stata. I have repeated events for each subject together with intervals of time in which an event happens or not. They are mothers which are followed to study their career breaks. I also have the total number of children they have and the time of birth for each child, for example:
id event time0 time timefirstchild timesecondchild #children
1 1 0 10 5 8 2
1 1 15 20 5 8 2
1 0 24 32 5 8 2
2 1 0 7 9 14 2
2 1 8 12 9 14 2
2 1 13 17 9 14 2
2 0 20 23 9 14 2
3 1 0 13 . . 0
3 0 14 18 . . 0
I would like to split each time span (time0-time) into segments defined by time0-timefirstchild, timefirstchild-timesecondchild and so on. Also I'd like to update a counting variable which increases of one each time the mother has a baby, in order to update her number of children over time. For example, I would like to get:
id event time0 time timefirstchild timesecondchild #children childrencount
1 1 0 5 5 8 2 1
1 1 8 15 5 8 2 2
1 0 15 20 5 8 2 2
2 1 0 7 9 14 2 0
2 1 8 9 9 14 2 1
2 1 9 12 9 14 2 1
2 0 13 14 9 14 2 2
2 0 14 17 9 14 2 2
2 0 20 23 9 14 2 2
3 1 0 13 . . 0 0
3 0 14 18 . . 0 0
Do you have any suggestion?
Thank you all in advance.
Anna
Related Posts with splitting time span
MCA rotationHello Stata friends! I am running MCA in stata and was checking the possibility of rotation after t…
Applying different colors to data points in scatter plotHi! I am trying to create a graph like the one below where I can apply different colors to data poin…
Sargan-Hansen testHi. I am trying to obtain results for the Sargan-Hansen test. However, when I run a regression usin…
Create indicator variables from multiple response string variableHi, I have a multiple response string variable, locnm_1, which lists the names of local sponsors of…
How to spread the reference's values to other observations at different yearsDear statalist, I have a dynamic panel for 20 years. However, data on one variable of interest is c…
Subscribe to:
Post Comments (Atom)
0 Response to splitting time span
Post a Comment