Hello all
I am trying to do a survival analysis where I am looking at the whether a clinical score (X) is associated with my outcome of death. I want to adjust for a medication that is prescribed which influences both the clinical score and the risk of death. X is a continuous variable, but I have a dichomotomized version X_di.
I have two databases, and in database 1, I have the following variables: id, age, sex, ethnicity, X, X_di time_of_origin, death_time, and death. Times are all in stata format.
Database 2 has id, drug_start_date, duration of prescription (days), but with multiple records per id (range is 1-500 prescriptions per id). The drug start date is in stata format.
Example of second dataset using dataex
I'm wondering how I go about modelling this drug as a time varying exposure. Would I have to use stset then stsplit after combining the two databases? Or do I have to manipulate the data in the second database first? There is only one dose for this drug - hence will not have to weight it.
Many thanks for your time!
I am trying to do a survival analysis where I am looking at the whether a clinical score (X) is associated with my outcome of death. I want to adjust for a medication that is prescribed which influences both the clinical score and the risk of death. X is a continuous variable, but I have a dichomotomized version X_di.
I have two databases, and in database 1, I have the following variables: id, age, sex, ethnicity, X, X_di time_of_origin, death_time, and death. Times are all in stata format.
Database 2 has id, drug_start_date, duration of prescription (days), but with multiple records per id (range is 1-500 prescriptions per id). The drug start date is in stata format.
Example of second dataset using dataex
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long id float drug_date long drug_dur 1002964 19575 28 1002964 19604 28 1002964 19631 28 1002964 19659 28 1002964 19687 28 1002964 19708 28 1002964 19708 28 1002964 19768 28 1002964 19775 28 1002964 19810 28 1002964 19855 28 1002964 19879 28 1002964 19904 28 1002964 19939 28 1002964 19962 28 1002964 19988 28 1002964 20016 28 1002964 20038 28 1002964 20072 28 1002964 20102 28 1002964 20131 28 1002964 20156 28 1002964 20186 28 1002964 20209 28 1002964 20237 28 1002964 20270 28 1002964 20298 28 1002964 20326 28 1002964 20326 28 1002964 20376 28 1002964 20409 28 1002964 20436 28 1002964 20436 28 1002964 20492 28 1002964 20520 28 1002964 20548 28 1002964 20579 28 1002964 20591 28 1003434 20570 56 1003768 19638 28 1003768 19673 28 1003768 19701 28 1003768 19733 28 1003768 19757 28 1003768 19768 28 1003768 19787 28 1003768 19823 28 1003768 19871 28 1003768 19898 28 1003768 19932 28 1003768 19957 28 1003768 19977 28 1003768 19992 28 1003768 20019 28 1003768 20052 28 1003768 20075 28 1003768 20118 28 1003768 20136 28 1003768 20170 28 1003768 20195 28 1003768 20234 28 1003768 20257 28 1003768 20279 28 1003768 20314 28 1003768 20341 28 1003768 20367 28 1003768 20395 28 1003768 20419 28 1003768 20458 28 1003768 20478 28 1003768 20514 28 1003768 20537 28 1003768 20569 28 1003768 20598 28 1003843 17192 28 1004863 20191 56 1004863 20234 56 1004863 20296 56 1004863 20354 56 1004863 20410 56 1004863 20464 56 1004863 20521 56 1004863 20583 56 1004863 20632 56 1004863 20688 56 1004863 20744 56 1004863 20795 30 1004863 20857 56 1004863 20915 56 1004916 16768 28 1004916 16786 28 1004916 16820 28 1005157 19534 30 1005157 19547 30 1005157 19568 30 1005157 19597 30 1005157 19619 30 1005157 19652 30 1005157 19680 30 1005157 19708 30 end format %td drug_date
Many thanks for your time!

Comment