I have a question how to create a dummy variable with certain conditions. I know how to create a dummy, however the certain conditions are making it difficult for me. I have large dataset ranging from 1980-2017 and I need to create a dummy variable that indicates that company has done at least 3 mergers within 5 years. I hope you can help me and I am using stata 14.

Example dataset
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int date double company_id byte event int event_date str30 AcquirorName float year
 9922 11951040 1  9922 "Montedison SpA"                1987
 9889 11966040 1  9889 "TI Group PLC"                  1987
 9894 12035040 1  9894 "Bank of Ireland PLC"           1987
10041 12062040 1 10041 "Henkel AG & Co KGaA"           1987
 9866 12136040 1  9866 "Whitbread & Co PLC"            1987
 9987 12319040 1  9987 "Next PLC"                      1987
10120 12381040 1 10120 "Henkel AG & Co KGaA"           1987
 9966 12469040 1  9966 "AGA AB"                        1987
 9987 12511040 1  9987 "Grand Metropolitan PLC"        1987
10010 12595040 1 10010 "VEBA AG"                       1987
10125 12973040 1 10125 "Ferranti International PLC"    1987
10041 13132040 1 10041 "News International PLC"        1987
10058 13226040 1 10058 "British & Commonwealth Hldgs"  1987
10044 13392040 1 10044 "Reed International PLC"        1987
10027 13568040 1 10027 "Williams Holdings PLC"         1987
 9932 13617040 1  9932 "British Aerospace PLC"         1987
 9884 13639040 1  9884 "Argyll Group PLC"              1987
10024 13761040 1 10024 "ICI PLC"                       1987
10013 14167040 1 10013 "Dowty Group PLC"               1987
 9623 14542040 1  9623 "Trafalgar House PLC"           1986
 9677 15253040 1  9677 "Next PLC"                      1986
 9708 15283040 1  9708 "British Electric Traction PLC" 1986
 9565 15384040 1  9565 "Ladbroke Group PLC"            1986
 9582 15688040 1  9582 "Britannia Arrow Holdings PLC"  1986
 9596 19262040 1  9596 "FH Tomkins PLC"                1986
 9728 19291040 1  9728 "British Printing & Commun"     1986
 9701 19461040 1  9701 "Vickers PLC"                   1986
 9707 20021040 1  9707 "Whitbread & Co PLC"            1986
 9952 20179040 1  9952 "Trelleborg AB"                 1987
10203 20371040 1 10203 "Williams Holdings PLC"         1987
10213 20579040 1 10213 "Cadbury Schweppes PLC"         1987
10206 21031040 1 10206 "Sears PLC"                     1987
10055 21251040 1 10055 "Williams Holdings PLC"         1987
 9846 21313040 1  9846 "Enterprise Oil PLC"            1986
10189 21538040 1 10189 "RTZ Corp PLC"                  1987
end
format %tdD_m_Y date
format %tdnn/dd/CCYY event_date