1. sort code EVENTDATE
by code: gen datenum=_n
by code: gen target=datenum if EVENTDATE==date
egen td=min(target), by(code)
drop target
gen dif=datenum-td
by code: gen event_window=1 if dif>=-10 & dif<=10
egen count_event_obs=count(event_window), by(code)
by code: gen estimation_window=1 if dif<-15 & dif>=-250
egen count_est_obs=count(estimation_window), by(code)
replace event_window=0 if event_window==.
replace estimation_window=0 if estimation_window==.
tab code if count_event_obs<21
tab code if count_est_obs<235
drop if count_event_obs <21
drop if count_est_obs <235
最后drop了之后数据都清空了,请问为什么一定要做这一步??
2. 要计算个股(-250,-15)日的mean normal return, 应该用什么命令??