Hi everyone,
I have a panel data (1960 to 1980) with multiple locations (lgacodes) and am trying to create a column with the first year of treatment for each location (to do Difference-in-Differences with multiple periods). I used this code:
bysort lgacodes: replace first_treat=min( year1_lga) if dummy_general==1
but it didn't work, so I used:
bysort lgacodes: replace first_treat= year1_lga if dummy_general==1
instead.
Now, I believe I have to create a foreach loop to replace 'first_treat' with the min (year1_lga) for each lgacodes, but not sure how to do it. Could you please help?
Many thanks,
Here is a sample of my data Array
Related Posts with Create a first.treat for DID with multiple periods
Decimal places control when exporting to tex file using logoutDear Statalists, I have a few numbers in my dta which I would like them to remain in this format (ro…
Power calculation using pairwise matching design.Hi All, For our cluster level specification, we are currently using “clustersampsi” command in Stat…
Latent Class Analysis - How to identify the main drivers?Hi All! I ran a LCA to identify the best possible segmentation of classes in a population. I used L…
Spectral decomposition in MataHi Mata users, I would like to know if there is a built-in function in Mata that calculates the squ…
Export trade durationHello, I am trying to assign consecutive years of exports to my data. My data consists of Years, pr…
Subscribe to:
Post Comments (Atom)
0 Response to Create a first.treat for DID with multiple periods
Post a Comment