Dear all Statalist, I am concerning the syntax for checking did released by Stata called xtdidregress.
I attached my dataset for investigating purpose. A glance of the dataset is below:
Array


year1 is the real year for each observation, TYPE2 is specific code for each firm. treat1 equal to 1 if this firm belongs to control group, and 0 otherwise, post33 equals to 1 for the after event date (2019). post33treat1 is the interaction of treat1 and post33. FAT_w1 is the dependent variable.

Yesterday, when applying the code xtdidregress, I faced a problem that the min and max of the first treatment observed for each firms varies (due to missing variable)


Code:
. xtdidregress (FAT_w1) (post33treat1), group(TYPE2) time(year1)

Number of groups and treatment time

Time variable: year1
Control:       post33treat1 = 0
Treatment:     post33treat1 = 1
-----------------------------------
             |   Control  Treatment
-------------+---------------------
Group        |
       TYPE2 |       274        264
-------------+---------------------
Time         |
     Minimum |      2016       2019
     Maximum |      2021       2021
-----------------------------------
After a discussion with Emil Alnor in this topic, it seems that I need to fix that the minimum and maximum of the second column both equal to 2019 to run the estate trendplots.
I tried to conduct these codes to delete all observations of any TYPE2 that has the first post33treat1 =1 at year after 2019.

Code:
bysort TYPE2 post33treat1 (year): generate indicator=1 if _n==1 & post33treat1==1
egen treataf19 = total(indicator==1 & year1!=2019) , by(TYPE2)
drop if treataf19
After that I run the xtdidregress again but the maximum of treatment here still not 2019 (it is 2020 now)

Code:
. xtdidregress (FAT_w1) (post33treat1), group(TYPE2) time(year1)

Number of groups and treatment time

Time variable: year1
Control:       post33treat1 = 0
Treatment:     post33treat1 = 1
-----------------------------------
             |   Control  Treatment
-------------+---------------------
Group        |
       TYPE2 |       274        248
-------------+---------------------
Time         |
     Minimum |      2016       2019
     Maximum |      2021       2020
-----------------------------------


I also cross check whether there is any TYPE2 that has the first post33treat1 observation equalling to 1 associated with the year1=2020 but it returns 0. I am wondering what's wrong with my coding progress and how to fix it.

Code:
 count if (indicator==1 & year1==2020)
  0

Thanks in advance and best regards.