I am trying to run this loop. I need to get two subsamples of frequent and occasional acquirers. the first one represents firms that made at least 2 deals over a 3 year window and the second one firms that made at least 5 deals over a 3 year window. My sample period is 1990-2011.
This is what I have so far but STATA gives me error "variable count already defined" and I can't figure out how to solve this.
Does anyone have any advice?
Thanks in advance!
Code:
forval year = 1990(1)2011{ keep if year >= `year' keep if year <= `year' + 3 gen count =. replace count = 1 collapse (sum) count (first) year, by(AcquirorCUSIP) keep if count > 2 if `year' > 1990{ append using frequent_acq.dta } save frequent_acq.dta, replace }
0 Response to Gen a variable in a loop: error "variable already defined"
Post a Comment