I want to generate the variables age_ma, d_1 and d_2 using the id_firm, year, and buyer
This is how it is
but I want it to be like this, the age_ma will start counting the year after buyer is equal 1 for each panel id. d_1 will take the value of 1 a year after buyer=1 and d_2 will take a value of 1, 2 years after buyer=1
This is how it is
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id_firm int year byte buyer float(age_ma d_1 d_2) 51 2005 0 . . . 51 2006 0 . . . 51 2007 0 . . . 51 2008 0 . . . 51 2009 0 . . . 51 2010 0 . . . 51 2011 0 . . . 51 2012 0 . . . 51 2013 0 . . . 51 2014 0 . . . 51 2015 0 . . . 51 2016 1 . . . 51 2017 0 . . . 51 2019 0 . . . 73 2004 0 . . . 73 2005 0 . . . 73 2006 1 . . . 73 2007 1 . . . 73 2009 1 . . . 73 2010 0 . . . 73 2011 0 . . . 73 2012 0 . . . 73 2013 1 . . . 73 2014 1 . . . 73 2015 0 . . . 73 2016 0 . . . 73 2017 0 . . . 73 2018 0 . . . 73 2019 0 . . . 73 2020 0 . . . 269 2004 0 . . . 269 2005 0 . . . 269 2006 0 . . . 269 2007 1 . . . 269 2008 0 . . . 269 2009 0 . . . 269 2010 0 . . . 269 2011 0 . . . 269 2012 0 . . . 269 2013 0 . . . 269 2014 1 . . . 269 2015 1 . . . 269 2016 0 . . . 269 2017 0 . . . 269 2018 0 . . . 269 2019 0 . . . 269 2020 0 . . . 298 2013 0 . . . 298 2014 0 . . . 298 2015 0 . . . 298 2016 0 . . . 298 2017 1 . . . 298 2018 0 . . . 298 2019 0 . . . 298 2020 1 . . . 326 2004 0 . . . 326 2005 0 . . . 326 2006 1 . . . 326 2007 0 . . . 326 2008 0 . . . 326 2009 0 . . . 326 2010 0 . . . 326 2011 0 . . . 326 2013 0 . . . 326 2014 0 . . . 326 2015 0 . . . 326 2016 0 . . . 326 2017 0 . . . end format %ty year
but I want it to be like this, the age_ma will start counting the year after buyer is equal 1 for each panel id. d_1 will take the value of 1 a year after buyer=1 and d_2 will take a value of 1, 2 years after buyer=1
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id_firm int year byte buyer float(age_ma d_1 d_2) 51 2005 0 . . . 51 2006 0 . . . 51 2007 0 . . . 51 2008 0 . . . 51 2009 0 . . . 51 2010 0 . . . 51 2011 0 . . . 51 2012 0 . . . 51 2013 0 . . . 51 2014 0 . . . 51 2015 0 . . . 51 2016 1 . . . 51 2017 0 1 1 . 51 2019 0 2 . 1 73 2004 0 . . . 73 2005 0 . . . 73 2006 1 . . . 73 2007 1 1 1 . 73 2009 1 2 1 1 73 2010 0 3 1 1 73 2011 0 5 . 1 73 2012 0 6 . . 73 2013 1 7 . . 73 2014 1 8 1 . 73 2015 0 9 1 1 73 2016 0 10 . 1 73 2017 0 11 . . 73 2018 0 12 . . 73 2019 0 13 . . 73 2020 0 14 . . 269 2004 0 . . . 269 2005 0 . . . 269 2006 0 . . . 269 2007 1 . . . 269 2008 0 1 1 . 269 2009 0 2 . 1 269 2010 0 3 . . 269 2011 0 4 . . 269 2012 0 5 . . 269 2013 0 6 . . 269 2014 1 7 . . 269 2015 1 8 1 . 269 2016 0 9 1 1 269 2017 0 10 . 1 269 2018 0 11 . . 269 2019 0 12 . . 269 2020 0 13 . . end format %ty year
Comment