Hello,
Please I need help creating a dummy variable Breached_Pre that is =1 in any of the prior 3 years to the Year when the Breached_firm==1. I have multiple firm-year observations, so the normal _n-1, _n-2 and _n-3 does not work.
For example, if Breached_firm==1 for Apple Co. in 2020, I want the Breached_Pre to be =1 in 2019, 2018 and 2017.
I look forward to your support!
Please I need help creating a dummy variable Breached_Pre that is =1 in any of the prior 3 years to the Year when the Breached_firm==1. I have multiple firm-year observations, so the normal _n-1, _n-2 and _n-3 does not work.
For example, if Breached_firm==1 for Apple Co. in 2020, I want the Breached_Pre to be =1 in 2019, 2018 and 2017.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float Year str551 Company float Breached_firm 2007 "024 Pharma, Inc." 0 2008 "024 Pharma, Inc." 0 2009 "024 Pharma, Inc." 0 2010 "024 Pharma, Inc." 0 2011 "024 Pharma, Inc." 0 2018 "10x Genomics, Inc." 0 2018 "10x Genomics, Inc." 0 2018 "10x Genomics, Inc." 0 2019 "10x Genomics, Inc." 0 2019 "10x Genomics, Inc." 0 2020 "10x Genomics, Inc." 0 2020 "10x Genomics, Inc." 0 2021 "10x Genomics, Inc." 0 2021 "10x Genomics, Inc." 0 2022 "10x Genomics, Inc." 0 2022 "10x Genomics, Inc." 0 2023 "10x Genomics, Inc." 0 2023 "10x Genomics, Inc." 0 2020 "1606 CORP." 0 2020 "1606 CORP." 0 2021 "1606 CORP." 0 2022 "1606 CORP." 0 2022 "1606 CORP." 0 2023 "1606 CORP." 0 2023 "1606 CORP." 0 2007 "180 DEGREE CAPITAL CORP. /NY/" 0 2008 "180 DEGREE CAPITAL CORP. /NY/" 0 2009 "180 DEGREE CAPITAL CORP. /NY/" 0 2010 "180 DEGREE CAPITAL CORP. /NY/" 0 2011 "180 DEGREE CAPITAL CORP. /NY/" 0 2012 "180 DEGREE CAPITAL CORP. /NY/" 0 2013 "180 DEGREE CAPITAL CORP. /NY/" 0 2014 "180 DEGREE CAPITAL CORP. /NY/" 0 2014 "180 DEGREE CAPITAL CORP. /NY/" 0 2015 "180 DEGREE CAPITAL CORP. /NY/" 0 2016 "180 DEGREE CAPITAL CORP. /NY/" 0 2016 "180 DEGREE CAPITAL CORP. /NY/" 0 2017 "180 DEGREE CAPITAL CORP. /NY/" 0 2018 "180 DEGREE CAPITAL CORP. /NY/" 0 2019 "180 DEGREE CAPITAL CORP. /NY/" 0 2020 "180 DEGREE CAPITAL CORP. /NY/" 0 2021 "180 DEGREE CAPITAL CORP. /NY/" 0 2022 "180 DEGREE CAPITAL CORP. /NY/" 0 2023 "180 DEGREE CAPITAL CORP. /NY/" 0 2016 "180 Life Sciences Corp." 0 2016 "180 Life Sciences Corp." 0 2016 "180 Life Sciences Corp." 0 2016 "180 Life Sciences Corp." 0 2017 "180 Life Sciences Corp." 0 2017 "180 Life Sciences Corp." 0 2018 "180 Life Sciences Corp." 0 2018 "180 Life Sciences Corp." 0 2019 "180 Life Sciences Corp." 0 2019 "180 Life Sciences Corp." 0 2020 "180 Life Sciences Corp." 0 2020 "180 Life Sciences Corp." 0 2021 "180 Life Sciences Corp." 0 2021 "180 Life Sciences Corp." 0 2022 "180 Life Sciences Corp." 0 2022 "180 Life Sciences Corp." 0 2023 "180 Life Sciences Corp." 0 2013 "1847 Holdings LLC" 0 2013 "1847 Holdings LLC" 0 2014 "1847 Holdings LLC" 0 2015 "1847 Holdings LLC" 0 2016 "1847 Holdings LLC" 0 2016 "1847 Holdings LLC" 0 2017 "1847 Holdings LLC" 0 2018 "1847 Holdings LLC" 0 2018 "1847 Holdings LLC" 0 2019 "1847 Holdings LLC" 0 2019 "1847 Holdings LLC" 0 2020 "1847 Holdings LLC" 0 2020 "1847 Holdings LLC" 0 2020 "1847 Holdings LLC" 0 2021 "1847 Holdings LLC" 0 2021 "1847 Holdings LLC" 0 2021 "1847 Holdings LLC" 0 2022 "1847 Holdings LLC" 0 2022 "1847 Holdings LLC" 0 2023 "1847 Holdings LLC" 0 2023 "1847 Holdings LLC" 0 2018 "1895 Bancorp of Wisconsin, Inc." 0 2018 "1895 Bancorp of Wisconsin, Inc." 0 2019 "1895 Bancorp of Wisconsin, Inc." 0 2019 "1895 Bancorp of Wisconsin, Inc." 0 2020 "1895 Bancorp of Wisconsin, Inc." 0 2020 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2020 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2020 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2021 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2021 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2022 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2022 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2023 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2023 "1895 Bancorp of Wisconsin, Inc. /MD/" 0 2007 "1ST SOURCE CORP" 0 2008 "1ST SOURCE CORP" 0 2009 "1ST SOURCE CORP" 0 2010 "1ST SOURCE CORP" 0 end
Comment