I have a panel dataset comprising three variables:
- ID
 - Date-quarter
 - transdummy
 
If M&A activity has occurred (transdummy = 1), I want to make transdummy = 1 in the following 12 quarters. This way, transdummy would equal 1 if M&A activity has occurred for a particular ID in any of the past 12 quarters (3 years).
For example, if transdummy = 1 in 2000:Q1. I want to make transdummy = 1 in 2000:Q2, 2000:Q3, ... 2003:Q1.
I tried the following
Code:
         bysort rssd9001: gen transdummy2 = 1 if transdummy[_n-12] == 1 |  ///
            transdummy[_n-11] == 1 |       ///
            transdummy[_n-10] == 1 |       ///
            transdummy[_n-9] == 1 |        ///
            transdummy[_n-8] == 1 |        ///
            transdummy[_n-7] == 1 |        ///
            transdummy[_n-6] == 1 |        ///
            transdummy[_n-5] == 1 |        ///
            transdummy[_n-4] == 1 |        ///
            transdummy[_n-3] == 1 |        ///
            transdummy[_n-2] == 1 |        ///
            transdummy[_n-1] == 1 |        ///
            transdummy == 1
drop transdummy
rename transdummy2 transdummyI would really appreciate any help on how I can solve this problem. It seems pretty straightforward and is probably an easy problem for an experienced Stata user.
Thanks.
0 Response to Extending dummy variable flag over multiple dates
Post a Comment