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
doiplot - postestimation module after metan for plots that address asymmetry or heterogeneityDear All There is now a post-estimation command after metan to visualize studies in meta-analysis t…
recovering the estimate of an interaction term using margins when the base level of all zeros is not includedHi Fellow Statalisters, In a recent posting (https://www.statalist.org/forums/forum/general-stata-d…
Identifying first and second re-admissions in a health datasetI am working with Stata/MP 15.1 and have appended two datasets. Database 1 includes a list of patie…
One line code for performing arithmetic operation (here multiplication) while merging two datasetsSuppose, I have two datasets given below, now how can I merge the datasets so that resulting values …
catplot - how to show n to the left of the bars, percentages within bars, and mean values outside the bars (to the right)Dear all, I am using the community-contributed command catplot from SSC in Stata 16.1 in order to p…
Subscribe to:
Post Comments (Atom)
0 Response to splitting time span
Post a Comment