Great! Thank you
In regards to the the former code where i have only included patients with first ever stroke:
Some of these patients/person_id's have more than one stroke in the follow-up period. Is it possible to set up the commands, so patients contribute with time at risk until their second stroke, if they do not have a fracture before that time?
So patients are followed until fracture or second stroke or death or end of follow up. Hope that makes sense
In regards to the the former code where i have only included patients with first ever stroke:
Code:
sort person_id stroke_date by person_id (stroke_date): gen start_follow_date = stroke_date[1] by person_id (admission_date), sort: egen first_post_stroke_fx_date = /// min(cond(has_fracture_now & admission_date > start_follow_date, admission_date, .)) by person_id: egen diagnosiscode = min(cond(admissiondate == first_post_stroke_fx_date, diag, .)) by person_id (admission_date): gen end_follow_date = min(td(31dec2017), dødsdato) by person_id: egen had_fracture = max(has_fracture_now) gen dead = 1 replace dead = 0 if missing(death_date) by person_id: egen died = max(dead) by person_id: keep if _n == 1
So patients are followed until fracture or second stroke or death or end of follow up. Hope that makes sense
Comment