Hello,

I am new to the Stata community and was hoping for some help with panel data analysis. I have health care data with 'clientid' as the panel variable. However, a client may have multiple visits on the same day with different or missing data recorded on the outcome variable (surveyid provides a unique identifier for observations on the same day). Here is a sample of my dataset:

clientid date medfreq severity surveyid
1 01/02/18 1 4 12345
1 02/21/18 4 12789
1 03/08/18 12890
1 06/15/18 3 2 12990
2 01/02/18 4 12681
2 01/02/18 2 3 12688
2 03/08/18 1 3 13450
2 06/15/18 3 3 13560

I have declared my dataset as panel data without indicating the time variable since there are repeated dates, which I want to preserve. Is this the correct approach?

I want to identify the first and last occurrences that are ≥3 months apart with data recorded on "medfreq." I would then like to run a xtab to see how clients changed over time from their first to last occurrence. I didn't find any literature on this specific issue but would be grateful for any suggested code or if someone can kindly refer me to an existing reference.

Thank you,
Samira