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
Decay measure variable using unbalanced panel dataHello everybody, I would really appreciate any help someone can provide with some coding. I am tryi…
Time dummies in xtabond and xtdpdsysHi, I made three year dummies. One is for 2005-2006, second is for 2007-2013 and third is for 2014-…
Interpretation of interaction term with ologit regressionHi all, I have a question about the interpretation of my results, regarding a moderator in an ologi…
Coding for three groups - cases, controls , and other diseases - What a dilemma!Hi Statalist, I am new her but I have learned a lot from you so far, so thank you all. I am using …
Access instance, class, or function "own" identifiers within the .class fileIn class programming, is there a way to access an instance's, class's or member function's own ident…
Subscribe to:
Post Comments (Atom)
0 Response to splitting time span
Post a Comment