data have;
input company$ date profit;
datalines;
a 199701 5
b 201404 6
f 200004 78
;
run;
data want
input company$ date EPS;
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;
/*the result should be*/
data rusult;
input company$ date EPS;
datalines;
a 199608 5
a 199706 30
a 199605 4
a 199712 9
b 201304 3
b 201305 6
b 201306 8
b 201504 80
;
run; ok, I want the result as above. Because 'a' and 'b' are also in data 'have', they should be selected. As for 'b', the date in 'have' is 201404, so the date in 'want' should be in (201304 to 201303) and in (201405 to 201504), and I get the 'EPS' I want. The last observation of b in data 'want' should be excluded for the date is out of one year range. I don't know if I express my idea well enough to be understood. If any question , pls let me know. Thank u very much.
... View more