Hello everyone. This is my first post here, I have been looking for information on how to do this but have yet to find a way. I am working with an unbalanced panel data set for my thesis and I want to use did_imputation. One of the required input variables is Ei. It indicates when a unit was first treated. It takes the value . (missing) for all observations of units that were never treated, and the value of the period of first treatment for all observations of units that were.

My data is for years 2008 to 2021, and the first treated units appear in 2009. This is an example of how I would like the data to look for one unit when the unit was treated in 2013 and one that was never treated:
unit year treatment firsttreat
1 2008 0 2013
1 2009 0 2013
1 2010 0 2013
1 2011 0 2013
1 2012 0 2013
1 2013 1 2013
1 2014 1 2013
1 2015 1 2013
1 2016 1 2013
1 2017 1 2013
1 2018 1 2013
1 2019 1 2013
1 2020 1 2013
1 2021 1 2013
2 2012 0 .
2 2013 0 .
2 2014 0 .
2 2015 0 .
2 2016 0 .
2 2017 0 .
2 2018 0 .
2 2019 0 .
2 2020 0 .
2 2021 0 .

I am honestly at a complete loss as to how I could go about this. I would very much appreciate any help.