I have a panel dataset, monthly between 1998m12-2018m12 for 28 countries. Here is an example of the dataset:
Code:
input Country startdate enddate "Austria" 1999m2 1999m4 "Austria" 2012m7 2012m9 "Austria" 2015m1 2015m3 "Austria" 2016m8 2016m9 "Belgium" 2005m8 2005m10
I want to create a crisis dummy which takes a value of 1 for all the dates between 'startdate' and 'enddate'. I achieved that, but I struggle to convert these data into a balanced panel in long format. This is what I want to achieve:
Code:
Country date crisis Austria 1998m12 0 Austria 1999m1 0 Austria 1999m2 1 Austria 1999m3 1 Austria 1999m4 1 Austria 1999m5 0 ... ... ... Austria 2018m12 0 Belgium 1998m1 0 Belgium 1999m2 0 ... ... ...
I found useful examples here and there, but it's not exactly what I want to do. I believe that the process involve expand and tsfill, but I don't know precisely what to do with these commands.
Thanks for your help,
Pierre
0 Response to Generate dummies with start and end dates, and convert data to long format
Post a Comment