My dataset has 2 grouping variables: ID and drug name
Also date for starting the treatment with a certain drug but per one drug can be several dates or the date is missing, I need to select the earliest date within a drug.
Data looks like this:
I know command bysort id : egen mindate = min(start_date)
But this does not work for me because one person may have multiple starting dates when starting with a new drug. I would be very grateful if anyone could help.
Also date for starting the treatment with a certain drug but per one drug can be several dates or the date is missing, I need to select the earliest date within a drug.
Data looks like this:
patient_id | start_date | drug |
1562 | 07.01.2019 | drug1 |
1562 | 15.04.2019 | drug1 |
1562 | 15.04.2019 | drug1 |
1562 | 15.04.2019 | drug1 |
1562 | 18.03.2020 | drug1 |
1562 | . | drug1 |
1562 | 18.03.2020 | drug1 |
1562 | 08.11.2022 | drug2 |
1562 | 08.11.2022 | drug2 |
1562 | 21.02.2023 | drug3 |
But this does not work for me because one person may have multiple starting dates when starting with a new drug. I would be very grateful if anyone could help.
Comment