I am looking to fill in missing observations for a dummy variable for firms (which each have an individual id number) across a number of years. It is an unbalanced panel data set. I recently expanded my dataset significantly to cover many more years and would like to fill in the rest of the observations relating to a dummy variable across the new years included. (As opposed to going through each firm manually, as there are around 2,000 firms for which the dummy variable equals 1).
The data currently looks as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 FirmID float(Year Dummy) "FR1234" 2003 . "FR1234" 2004 . "FR1234" 2005 . "FR1234" 2006 . "FR1234" 2007 . "FR1234" 2008 . "FR1234" 2009 . "FR1234" 2010 . "FR1234" 2011 1 "FR1234" 2012 1 "FR1234" 2013 1 "FR1234" 2014 1 "FR5644" 2003 . "FR5644" 2004 . "FR5644" 2005 . "FR5644" 2006 . "FR5644" 2007 . "FR5644" 2008 . "FR5644" 2009 . "FR5644" 2010 . "FR5644" 2011 . "FR5644" 2012 0 "FR5644" 2013 0 "FR5644" 2014 0 "FR5644" 2015 0 "FR5644" 2016 0 "FR3562" 2003 . "FR3562" 2004 . "FR3562" 2005 . "FR3562" 2006 . "FR3562" 2007 . "FR3562" 2008 . "FR3562" 2009 1 "FR3562" 2010 1 "FR3562" 2011 1 "FR3562" 2012 1 "" . . "" . . "" . . "" . . end
Essentially I would like to set the dummy variable equal to 1 for all firms for whom it already equals 1 in other years (it is a time-invariant dummy variable).
I hope this is clear,
Paul
0 Response to Filling a time-invariant dummy variable down for new years in panel data after expanding a dataset
Post a Comment