Hi Statalist,
I am trying to count the number of treated firms among those identified by unique ID in the panel data. I tried the following, which generates the number of all observations in the treated group instead of the number of treated firms.
Could you help me with how to modify the code or suggest any better alternative options in order to check the number of treated firms? Thanks.
I am trying to count the number of treated firms among those identified by unique ID in the panel data. I tried the following, which generates the number of all observations in the treated group instead of the number of treated firms.
Could you help me with how to modify the code or suggest any better alternative options in order to check the number of treated firms? Thanks.
Code:
bys firmid treated: gen nvals = _n == 1 if treated == 1 bys firmid: egen count_treated = total(nvals) drop nvals
Comment