Hi, I got the answer use the code. data want;
merge
have_base (in=b rename=(date=date_b))
have_event (in=e)
;
by company;
if b and e;
if intnx('month',date_b, -12)<=date<=date_b;
/*if 0>=intck('month',date,date_b) >=-12;*/
drop profit date_b;
run; But actually my datas' structure is like this, and a in dataset 'have_base' has duplicated observations. But I also want it to be a benchmark. data have_base;
input company$ _date:$6. profit;
date = input(_date !! '01',yymmdd8.);
format date yymmn6.;
drop _date;
datalines;
a 199701 5
a 199606 9
b 201404 6
f 200004 78
;
run;
data have_event;
input company$ _date:$6. EPS;
date = input(_date !! '01',yymmdd8.);
format date yymmn6.;
drop _date;
datalines;
a 199608 5
a 199706 30
a 199605 4
a 199712 9
a 199806 10
c 201404 6
k 200004 78
n 198607 56
a 198504 3
b 201304 3
b 201305 6
b 201306 8
b 201504 80
b 201603 5
;
run; I want to get the result : a 199608 5 a 199605 4 a 199605 4 b 201304 3 b 201305 6 b 201306 8 actually, I have no any idea of that. Thanks a lot .
... View more