Hello there,
This is my first post but I am a long time reader of this forum, so thank you for all the help.
I have a dataset with several hundred thousand observations (participants) with in-patient diagnoses variables (ICD codes) and diagnoses dates. For example, there are 243 diagnoses variables (s_41270_0_0 to s_41270_0_242), so each participant can have up to 243 diagnoses. There are also 243 diagnoses dates that correspond to the 243 diagnoses (ts_41262_0_0-ts_41262_0_242).
I would like to create a variable for each participant that identifies if they have had a certain diagnosis within a certain range of dates. The diagnosis is COVID-19, which has two ICD codes U071 or U072. I have been able to create a variable that identifies whether or not they have had a COVID-19 diagnosis:
However, my problem is I don't know how to match the dates with each diagnosis to specify if their COVID-19 diagnosis was within a certain date range. I hope this makes sense. I cannot share the data because it is confidential but I am happy to provide more info for clairfication.
Thank you,
Andrew
This is my first post but I am a long time reader of this forum, so thank you for all the help.
I have a dataset with several hundred thousand observations (participants) with in-patient diagnoses variables (ICD codes) and diagnoses dates. For example, there are 243 diagnoses variables (s_41270_0_0 to s_41270_0_242), so each participant can have up to 243 diagnoses. There are also 243 diagnoses dates that correspond to the 243 diagnoses (ts_41262_0_0-ts_41262_0_242).
I would like to create a variable for each participant that identifies if they have had a certain diagnosis within a certain range of dates. The diagnosis is COVID-19, which has two ICD codes U071 or U072. I have been able to create a variable that identifies whether or not they have had a COVID-19 diagnosis:
Code:
generate COVID19hosp1=0 foreach var of varlist s_41270_0_0-s_41270_0_242 { replace COVID19hosp1=1 if `var'=="U071" | `var'=="U072" } tab COVID19hosp1
Thank you,
Andrew
Comment