Hi @Filipvdr
I had a look at Jim Moon's paper, and I notice that it relies heavily on the between-operator. It is a good approch to interval-joining small tables, but it is extremely slow when working with large tables, especially DBMS-tables.
The macro I mentioned in my previous post (attached) is developed to overcome that and work fast with big tables. We use it in many production jobs, where interval joins with between used to run up to 2 hours, and now run in as many minutes instead.
Given your test input, this is the call:
%fletrensinterval(
tableA,
tableB,
tableOUT,
unita=FKEY, datefirsta=FROM, datelasta=TO,
unitb=FKEY, datefirstb=fromb, datelastb=tob,
join=left,
byvarA=ID);
TableA and TableB are the input tables, and tableOUT the resulting output tables.
unita, datefirsta and datelasta are the variables holding the key to join on and the from- and to-dates i TableA.
unitb, datefirstb and datelastb are the variables holding the key to join on and the from- and to-dates i TableB.
Join=left preserves all keys/intervals in TableA, even if the key is not present in TableB, or (part of) an interval in TableA is outside corresponding intervals in TableB
ByvarA=ID is the name of a grouping variable in TableA (in this case ID), so separate joins are made for each ID value i A, if the join key (in this case FKEY) exists with more than one ID in TableA
Result:
... View more