Dear all,
I have a panel dataset containing panel var (gvkey – firm identifier), time var (fyear, fiscal year), x (main variable), event (a dummy, =1 if an event occurs in that year for that firm).
You can see that for gvkey 1000, it has 2 events staggered in 2000 and 2002.
[CODE]
| gvkey fyear ap event f1_ap l1_ap d1_ap |
|----------------------------------------------------|
1. | 1000 1999 10 0 20 . . |
2. | 1000 2000 20 1 15 10 5 |
3. | 1000 2001 15 0 10 20 -10 |
4. | 1000 2002 10 1 . 15 . |
5. | 1001 1999 12 0 22 . . |
|----------------------------------------------------|
6. | 1001 2000 22 1 15 12 3 |
7. | 1001 2001 15 0 43 22 21 |
8. | 1001 2002 43 0 . 15 . |
+----------------------------------------------------+
. clear
. import excel "C:\Edrive\Stata Learning\Stagger Events\New Microsoft Excel Worksheet.xlsx", sheet("Test change AP = did") firstrow
. dataex
I will conduct a Difference in difference (DID) regression analysis.
The basic DID we need to have a treat dummy and a post dummy.
My question concerns how to generate the post dummy :
p.s. if you know about staggered events, please comment on if I should reset post to 0 when encountering second events.
Thanks,
Rochelle
I have a panel dataset containing panel var (gvkey – firm identifier), time var (fyear, fiscal year), x (main variable), event (a dummy, =1 if an event occurs in that year for that firm).
You can see that for gvkey 1000, it has 2 events staggered in 2000 and 2002.
[CODE]
| gvkey fyear ap event f1_ap l1_ap d1_ap |
|----------------------------------------------------|
1. | 1000 1999 10 0 20 . . |
2. | 1000 2000 20 1 15 10 5 |
3. | 1000 2001 15 0 10 20 -10 |
4. | 1000 2002 10 1 . 15 . |
5. | 1001 1999 12 0 22 . . |
|----------------------------------------------------|
6. | 1001 2000 22 1 15 12 3 |
7. | 1001 2001 15 0 43 22 21 |
8. | 1001 2002 43 0 . 15 . |
+----------------------------------------------------+
. clear
. import excel "C:\Edrive\Stata Learning\Stagger Events\New Microsoft Excel Worksheet.xlsx", sheet("Test change AP = did") firstrow
. dataex
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(gvkey fyear) byte(x event) 1000 1999 10 0 1000 2000 20 1 1000 2001 15 0 1000 2002 10 1 1001 1999 12 0 1001 2000 22 1 1001 2001 15 0 1001 2002 43 0 1002 2000 15 0 1002 2001 10 0 end
The basic DID we need to have a treat dummy and a post dummy.
My question concerns how to generate the post dummy :
- For gvkey 1000,if post=1 for years following event, i.e. 2000, 2001, 2002, 2003, how do I reset post for the second event in year 2002 ,
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(gvkey fyear) byte(x event post) 1000 1999 10 0 0 1000 2000 20 1 1 1000 2001 15 0 1 1000 2002 10 1 0 1000 2003 5 0 1 1001 1999 12 0 0 1001 2000 22 1 0 1001 2001 15 0 1 1001 2002 43 0 1 1002 2000 15 0 0 1002 2001 10 0 0 end
Thanks,
Rochelle
Comment