2 ways to do this, using either sql or a data step:
data A;
do I=1 to 1e4;
A=int(ranuni(0)*22);
A1=int(ranuni(0)*100000);
A2=A1+10;
output;
end;
run;
data B(index=(B));
do I=1 to 1e6;
B=int(ranuni(0)*22);
B1=int(ranuni(0)*100000);
B2=B1+10;
output;
end;
run;
proc sql; * join using sql;
create table C as
select *
from A
left join B
on A=B and (A1<=B1<=A2 or A1<=B2<=A2 or B1<=A1<=B2 or B1<=A2<=B2);
quit;
sql is a lot faster in this case (30s on my PC) using my data sample.
Hash tables might be faster but the key is not unique and I don't have 9.2 to test.
Message was edited by: Chris@NewZealand
Removed data step