我正在进行事件研究,需要返回的平均值才能产生异常回报。我的基准窗口是[-60,-11],我的事件窗口是[-5,-1],0为公告日期。但是,我有几个公告可能会污染基准和事件窗口。 不过,我想保持50天的基准窗口保持不变,因此,如果基准窗口中有通知,请删除此日并将窗口延长1.
现在我使用proc expand生成平均值:
proc expand; by stock;
convert logreturn = avg_logreturn / METHOD = none TRANSFORMOUT = (movave 60 lag 11);
运行;
然后从实际回报中扣除平均值。
我的数据集看起来像这样(10年的数据):
Stock Date Return Announcement
AAA 01/01/10 0.05
AAA 02/01/10 0.04
AAA 03/01/10 -0.02 03/01/10 this one should be deleted as is spoils the coming announcement but still be counted as an announcement
AAA 04/01/10 0.01
AAA 05/01/10 -0.03
AAA 06/01/10 0.05
AAA 07/01/10 0.04
AAA 08/01/10 -0.02 08/01/10
AAA 09/01/10 0.01
AAA 10/01/10 -0.03
AAB 01/01/10 0.01
等
基本上,每个公告需要一个-60到-11的窗口,我计算其平均值。长度应保持不变,但如果在此窗口中有其他公告,则不应计算该平均值。
这个想法很简单,但实现似乎很复杂......
答案 0 :(得分:0)
预处理要扩展的数据。
示例代码:
data have;
attrib
stock length=$3
date length=4 format=date9. informat=mmddyy8.
return length=8 format=6.2
announcement length=4 format=date9. informat=mmddyy8.
;
infile cards missover;
input stock date return announcement;
datalines;
AAA 01/01/10 0.05
AAA 02/01/10 0.04
AAA 03/01/10 -0.02 03/01/10 this one should be deleted as is spoils the coming announcement but still be counted as an announcement
AAA 04/01/10 0.01
AAA 05/01/10 -0.03
AAA 06/01/10 0.05
AAA 07/01/10 0.04
AAA 08/01/10 -0.02 08/01/10
AAA 09/01/10 0.01
AAA 10/01/10 -0.03
AAB 01/01/10 0.01
run;
%let CULL_GAP_LE_CRITERIA = 5 ;
data cull(keep=stock cull_date);
set have;
by stock date;
retain cull_date;
if first.stock then cull_date = .;
if announcement then do;
if cull_date then do;
gap = intck('month', cull_date, announcement);
if gap <= &CULL_GAP_LE_CRITERIA then
OUTPUT;
end;
cull_date = announcement; * setup for culling this announcement as well;
put cull_date=;
end;
run;
data DATA_FOR_EXPAND / view=DATA_FOR_EXPAND;
merge
have
cull(rename=cull_date=date in=culled)
;
by stock date;
if not culled;
run;
if not culled
将删除已淘汰的行。我认为这对你是正确的,因为你说窗口增加了1。
如果您希望在滚动窗口之前使用已淘汰的日期,那么您会有一些泡菜。