Hi everyone,
I am currently working on generating Kaplan-Meier estimates for a survival function. To start, I need to calculate variables representing the time intervals between consecutive births, which I’ll call duration1_2, duration2_3, ..., up to duration10_11. For example, duration1_2 will show the time in months between the first and second child, duration2_3 will show the interval between the second and third child, and so on up to duration10_11, which represents the time between the tenth and eleventh child.
Next, I want to create a set of "failure" variables (failure1_2, failure2_3, ..., failure10_11). Each failure variable will be a dummy indicator: it will be set to 1 if the corresponding duration is less than 24 months, and 0 otherwise.
Additionally, I plan to calculate duration_trunc, which will represent the time (in months) between a woman's last recorded birth and the survey date. If a woman has fewer than 9 children, duration_trunc will be assigned a value of 1000 months to indicate censoring.
I’ll display the dataset and show the transformation steps I plan to take to prepare it for Kaplan-Meier analysis. Key variables in my dataset include caseid, v007, seq, b19, and v201.
Let me know if any part needs clarification
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------------------
caseid str15 %15s case identification
v007 int %8.0g year of interview
seq str3 %9s
b19 int %8.0g current age of child in months
v201 byte %8.0g total children ever born
the above ae the currently existing variables
dataex caseid v007 seq b19 v201
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 100 out of 301360 observations
Use the count() option to list more
now i will present how i want to transform my dataset into
dataex id duration1_2 duration2_3 duration3_4 duration4_5 failure1_2 failure2_3 failure3_4
> failure4_5 failure5_6 duration_n failure_n
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 100 out of 2016 observations
Use the count() option to list more
.
I am currently working on generating Kaplan-Meier estimates for a survival function. To start, I need to calculate variables representing the time intervals between consecutive births, which I’ll call duration1_2, duration2_3, ..., up to duration10_11. For example, duration1_2 will show the time in months between the first and second child, duration2_3 will show the interval between the second and third child, and so on up to duration10_11, which represents the time between the tenth and eleventh child.
Next, I want to create a set of "failure" variables (failure1_2, failure2_3, ..., failure10_11). Each failure variable will be a dummy indicator: it will be set to 1 if the corresponding duration is less than 24 months, and 0 otherwise.
Additionally, I plan to calculate duration_trunc, which will represent the time (in months) between a woman's last recorded birth and the survey date. If a woman has fewer than 9 children, duration_trunc will be assigned a value of 1000 months to indicate censoring.
I’ll display the dataset and show the transformation steps I plan to take to prepare it for Kaplan-Meier analysis. Key variables in my dataset include caseid, v007, seq, b19, and v201.
Let me know if any part needs clarification
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------------------
caseid str15 %15s case identification
v007 int %8.0g year of interview
seq str3 %9s
b19 int %8.0g current age of child in months
v201 byte %8.0g total children ever born
the above ae the currently existing variables
dataex caseid v007 seq b19 v201
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str15 caseid int v007 str3 seq int b19 byte v201 " 1 1 2" 2018 "_01" 42 5 " 1 1 2" 2018 "_02" 111 5 " 1 1 2" 2018 "_03" 134 5 " 1 1 2" 2018 "_04" 160 5 " 1 1 2" 2018 "_05" 187 5 " 1 1 2" 2018 "_06" . 5 " 1 1 2" 2018 "_07" . 5 " 1 1 2" 2018 "_08" . 5 " 1 1 2" 2018 "_09" . 5 " 1 1 2" 2018 "_10" . 5 " 1 1 2" 2018 "_11" . 5 " 1 1 2" 2018 "_12" . 5 " 1 1 2" 2018 "_13" . 5 " 1 1 2" 2018 "_14" . 5 " 1 1 2" 2018 "_15" . 5 " 1 1 2" 2018 "_16" . 5 " 1 1 2" 2018 "_17" . 5 " 1 1 2" 2018 "_18" . 5 " 1 1 2" 2018 "_19" . 5 " 1 1 2" 2018 "_20" . 5 " 1 4 1" 2018 "_01" 66 5 " 1 4 1" 2018 "_02" 93 5 " 1 4 1" 2018 "_03" 159 5 " 1 4 1" 2018 "_04" 184 5 " 1 4 1" 2018 "_05" 212 5 " 1 4 1" 2018 "_06" . 5 " 1 4 1" 2018 "_07" . 5 " 1 4 1" 2018 "_08" . 5 " 1 4 1" 2018 "_09" . 5 " 1 4 1" 2018 "_10" . 5 " 1 4 1" 2018 "_11" . 5 " 1 4 1" 2018 "_12" . 5 " 1 4 1" 2018 "_13" . 5 " 1 4 1" 2018 "_14" . 5 " 1 4 1" 2018 "_15" . 5 " 1 4 1" 2018 "_16" . 5 " 1 4 1" 2018 "_17" . 5 " 1 4 1" 2018 "_18" . 5 " 1 4 1" 2018 "_19" . 5 " 1 4 1" 2018 "_20" . 5 " 1 5 2" 2018 "_01" 73 5 " 1 5 2" 2018 "_02" 104 5 " 1 5 2" 2018 "_03" 115 5 " 1 5 2" 2018 "_04" 147 5 " 1 5 2" 2018 "_05" 196 5 " 1 5 2" 2018 "_06" . 5 " 1 5 2" 2018 "_07" . 5 " 1 5 2" 2018 "_08" . 5 " 1 5 2" 2018 "_09" . 5 " 1 5 2" 2018 "_10" . 5 " 1 5 2" 2018 "_11" . 5 " 1 5 2" 2018 "_12" . 5 " 1 5 2" 2018 "_13" . 5 " 1 5 2" 2018 "_14" . 5 " 1 5 2" 2018 "_15" . 5 " 1 5 2" 2018 "_16" . 5 " 1 5 2" 2018 "_17" . 5 " 1 5 2" 2018 "_18" . 5 " 1 5 2" 2018 "_19" . 5 " 1 5 2" 2018 "_20" . 5 " 1 6 2" 2018 "_01" 84 4 " 1 6 2" 2018 "_02" 134 4 " 1 6 2" 2018 "_03" 172 4 " 1 6 2" 2018 "_04" 222 4 " 1 6 2" 2018 "_05" . 4 " 1 6 2" 2018 "_06" . 4 " 1 6 2" 2018 "_07" . 4 " 1 6 2" 2018 "_08" . 4 " 1 6 2" 2018 "_09" . 4 " 1 6 2" 2018 "_10" . 4 " 1 6 2" 2018 "_11" . 4 " 1 6 2" 2018 "_12" . 4 " 1 6 2" 2018 "_13" . 4 " 1 6 2" 2018 "_14" . 4 " 1 6 2" 2018 "_15" . 4 " 1 6 2" 2018 "_16" . 4 " 1 6 2" 2018 "_17" . 4 " 1 6 2" 2018 "_18" . 4 " 1 6 2" 2018 "_19" . 4 " 1 6 2" 2018 "_20" . 4 " 1 7 2" 2018 "_01" . 0 " 1 7 2" 2018 "_02" . 0 " 1 7 2" 2018 "_03" . 0 " 1 7 2" 2018 "_04" . 0 " 1 7 2" 2018 "_05" . 0 " 1 7 2" 2018 "_06" . 0 " 1 7 2" 2018 "_07" . 0 " 1 7 2" 2018 "_08" . 0 " 1 7 2" 2018 "_09" . 0 " 1 7 2" 2018 "_10" . 0 " 1 7 2" 2018 "_11" . 0 " 1 7 2" 2018 "_12" . 0 " 1 7 2" 2018 "_13" . 0 " 1 7 2" 2018 "_14" . 0 " 1 7 2" 2018 "_15" . 0 " 1 7 2" 2018 "_16" . 0 " 1 7 2" 2018 "_17" . 0 " 1 7 2" 2018 "_18" . 0 " 1 7 2" 2018 "_19" . 0 " 1 7 2" 2018 "_20" . 0 end
Listed 100 out of 301360 observations
Use the count() option to list more
now i will present how i want to transform my dataset into
dataex id duration1_2 duration2_3 duration3_4 duration4_5 failure1_2 failure2_3 failure3_4
> failure4_5 failure5_6 duration_n failure_n
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id duration1_2 duration2_3 duration3_4 duration4_5 failure1_2 failure2_3 failure3_4 failure4_5 failure5_6 duration_n failure_n) 1020902 27 39 . . 1 0 . . . 27 1 1020902 27 39 . . 1 0 . . . 39 0 1030403 29 . 34 32 1 1 1 1 1 29 1 1030403 29 . 34 32 1 1 1 1 1 . 1 1030403 29 . 34 32 1 1 1 1 1 34 1 1030602 46 18 . . 1 0 . . . 46 1 1030602 46 18 . . 1 0 . . . 18 0 1031012 35 3 . . 1 0 . . . 35 1 1031012 35 3 . . 1 0 . . . 3 0 1031202 16 . . . 0 . . . . 16 0 1040212 25 24 46 . 1 1 0 . . 25 1 1040212 25 24 46 . 1 1 0 . . 24 1 1040212 25 24 46 . 1 1 0 . . 46 0 1040217 23 24 32 28 1 1 1 1 0 23 1 1040217 23 24 32 28 1 1 1 1 0 24 1 1040217 23 24 32 28 1 1 1 1 0 32 1 1040303 58 24 25 23 1 1 1 1 0 58 1 1040303 58 24 25 23 1 1 1 1 0 24 1 1040303 58 24 25 23 1 1 1 1 0 25 1 1040316 30 58 2 . 1 1 0 . . 30 1 1040316 30 58 2 . 1 1 0 . . 58 1 1040316 30 58 2 . 1 1 0 . . 2 0 1040702 32 . . . 0 . . . . 32 0 1040902 23 85 23 14 1 1 1 0 . 23 1 1040902 23 85 23 14 1 1 1 0 . 85 1 1040902 23 85 23 14 1 1 1 0 . 23 1 1041002 29 49 6 . 1 1 0 . . 29 1 1041002 29 49 6 . 1 1 0 . . 49 1 1041002 29 49 6 . 1 1 0 . . 6 0 1050109 15 . . . 0 . . . . 15 0 1050313 26 . . . 0 . . . . 26 0 1050605 24 40 46 3 1 1 1 0 . 24 1 1050605 24 40 46 3 1 1 1 0 . 40 1 1050605 24 40 46 3 1 1 1 0 . 46 1 1050612 27 4 . . 1 0 . . . 27 1 1050612 27 4 . . 1 0 . . . 4 0 1050702 23 . . . 0 . . . . 23 0 1051001 25 12 . . 1 0 . . . 25 1 1051001 25 12 . . 1 0 . . . 12 0 1060410 2 . . . 0 . . . . 2 0 1060414 60 . . . 0 . . . . 60 0 1070102 167 . . . 0 . . . . 167 0 1070403 13 . . . 0 . . . . 13 0 1070602 . . . . 1 0 . . . . 1 1070602 . . . . 1 0 . . . . 0 1070803 29 25 23 67 1 1 1 1 0 29 1 1070803 29 25 23 67 1 1 1 1 0 25 1 1070803 29 25 23 67 1 1 1 1 0 23 1 1071014 14 26 53 27 1 1 1 1 1 14 1 1071014 14 26 53 27 1 1 1 1 1 26 1 1071014 14 26 53 27 1 1 1 1 1 53 1 1071022 15 . . . 0 . . . . 15 0 1071025 53 25 37 . 1 1 0 . . 53 1 1071025 53 25 37 . 1 1 0 . . 25 1 1071025 53 25 37 . 1 1 0 . . 37 0 1071030 13 . . . 0 . . . . 13 0 1071109 36 12 96 36 1 1 1 1 0 36 1 1071109 36 12 96 36 1 1 1 1 0 12 1 1071109 36 12 96 36 1 1 1 1 0 96 1 1080408 86 . . . 0 . . . . 86 0 1090104 19 3 . . 1 0 . . . 19 1 1090104 19 3 . . 1 0 . . . 3 0 1090207 50 . . . 0 . . . . 50 0 1090209 52 . . . 0 . . . . 52 0 1100509 21 . . . 0 . . . . 21 0 1100816 26 32 . . 1 0 . . . 26 1 1100816 26 32 . . 1 0 . . . 32 0 1100824 26 32 38 34 1 1 1 0 . 26 1 1100824 26 32 38 34 1 1 1 0 . 32 1 1100824 26 32 38 34 1 1 1 0 . 38 1 1100829 26 . 22 . 1 1 0 . . 26 1 1100829 26 . 22 . 1 1 0 . . . 1 1100829 26 . 22 . 1 1 0 . . 22 0 1101012 200 2 . . 1 0 . . . 200 1 1101012 200 2 . . 1 0 . . . 2 0 1101016 56 . . . 0 . . . . 56 0 1101201 65 42 . . 1 0 . . . 65 1 1101201 65 42 . . 1 0 . . . 42 0 1110204 41 . . . 0 . . . . 41 0 1110502 20 28 43 52 1 1 1 0 . 20 1 1110502 20 28 43 52 1 1 1 0 . 28 1 1110502 20 28 43 52 1 1 1 0 . 43 1 1120102 36 . . . 1 1 0 . . 36 1 1120102 36 . . . 1 1 0 . . . 1 1120102 36 . . . 1 1 0 . . . 0 1120705 31 12 . . 1 0 . . . 31 1 1120705 31 12 . . 1 0 . . . 12 0 1130102 42 51 24 51 1 1 1 1 0 42 1 1130102 42 51 24 51 1 1 1 1 0 51 1 1130102 42 51 24 51 1 1 1 1 0 24 1 1130801 36 62 4 . 1 1 0 . . 36 1 1130801 36 62 4 . 1 1 0 . . 62 1 1130801 36 62 4 . 1 1 0 . . 4 0 1130901 57 . . . 0 . . . . 57 0 1131002 24 4 . . 1 0 . . . 24 1 1131002 24 4 . . 1 0 . . . 4 0 1140202 . . . . 1 0 . . . . 1 1140202 . . . . 1 0 . . . . 0 1140502 82 . . . 1 1 1 1 0 82 1 1140502 82 . . . 1 1 1 1 0 . 1 end
Listed 100 out of 2016 observations
Use the count() option to list more
.
Comment