[code:17nroeyc]data a;
input com date yymmdd8.;
format date yymmdd10.;
datalines;
1 20010201
1 20010302
1 20020508
2 20030102
2 20030105
3 20060203
;
data b;
input com effectdate yymmdd8. amt;
format effectdate yymmdd10.;
datalines;
1 20020202 10
1 20030101 15
2 20030104 20
2 20050101 30
3 20070101 14
;
data temp_b;
set b;
by com;
start=lag(effectdate);
if first.com then start=0;
rename effectdate=end;
format start yymmdd10.;
run;
proc sql;
create table c as
select a.com,date,amt
from a a left join temp_b b
on a.com=b.com and start<date<=end
order by a.com,date;
quit;[/code:17nroeyc]