date - match event windows (in month) using sas sql -


i have 2 files, 1 event date, other 1 security prices need match month event month 0, -1 (previous month), , +1 (the month after event month). e.g., 1 observation has event date 1/1/2010, have daily bond prices 1/1/2009 1/20/2010, need match january,2010 december 2009 prices , february 2010. have following codes that,

proc sql;  create table test   select *   bondprice a, sdc b b.participant_cusip=a.cusip  & intck('month',b.alliance_date,a.time)>=-1  & intck('month',b.alliance_date,a.time)<=1 ; quit;    data test1;  set test; deal_number cusip code time;  if first.code  price1=price;  if first.code  day1=time; if last.code  price0=price;  if last.code  day0=time; run; 

clearly observation should matched in 1-month jan 2010 (0,0) , 2-month dec 2009 jan 2010 (-1,0), because not have 3-month feb 2010's prices. however, if using codes above, yield valid obs has 3-month price since fell range of >=-1 , <=1. first part of code not accurate (the >= , <= range): yields prices falls december 2009 feb 2010, wrong because of 2 situations. first, if bond prices stops in between dec 2009 , jan 2010, counting valid 2-month , 3-month observations. second, if bond prices begins in between jan 2010 , feb 2010, counting valid 3-month observation. both of these 2 situation yield invalid observations, since first situation not have feb 2010 prices still counts 2-month , 3-month, , second situation not have either dec 2009 or jan 2010 prices, still counts 3-month.

will me this? how can modify code 3-month window , 2-month window contains relative months? hope describe problem clearly. please let me know if unclear. i've uploaded example problem here. https://www.dropbox.com/s/hx9ahst7nts4k0q/ex1.xlsx?dl=0

enter image description here


Comments