OK, here is my code. As you can see , before merge I format both variables to date format which is in best12. fomat originally. But I get the result as following. the result with red line is obviously wrong. data m_fegg;
set ibes.m_fegg;
cusip=substr(cusip,1,6);
format yymm yymmn6.;
run;
data sdc_final;
set sdc.sdc_final;
format yymm_a yymm_e yymmn6.;
run;
/*create the date before m&a*/
proc sql;
create table m_i_s1 as select b.*,a.yymm_a
from sdc_final as a,
m_fegg as b
where intnx('month',a.yymm_a,-36)<=b.yymm<=a.yymm_a
& a.acq_cusip=b.cusip;
quit;
data m_i_s1;
set m_i_s1;
format yymm_a yymm best12.; run;
... View more