Hello guys,

I am trying to calculate days elapsed for each 'episode' between x and y values. For example, the days elapsed in Episode 1 equals days between 12th March 2020 and 21st April 2020, Episode 2 is between 1st June 2020 and 11th January 2021 and so on. I was wondering if there is a way to do this in STATA in the panel format.

Id date x y Episode
1 12th March 2020 1 1
1 18th March 2020 1 1
1 21st April 2020 1 1
1 1ST June 2020 1 2
1 11 January 2021 1 2
1 06th June 2021 1 3
1 18th December 2021 1 3
1 02nd March 2022 1 3
1 15th April 2022 1 3
1 21st April 2022 1 4
1 24th April 2022 1 4