I am trying to left join two data sets based on a four digit code in each. One data set has the codes filled in to varying degrees (2,3, or all 4 digits) with trailing zeroes as needed.
The other data set has the codes completed to all four digits.
If the last two digits of CodeA are 00 then I want to join to any CodeB with the same first two digits. If only the last digit of CodeA is 0 then I want to join to all CodeBs that have the same first three digits. If CodeA has all four digits then I want to join to those exact same codes in CodeB.
Example:
CodeA data set
Example CodeA   Field1
1   2500    w
2   4110    x
3   2525    y
4   5345    z
CodeB data set
CodeB   Field2
1234    a
2525    b
4113    c
6543    d
5341    e
2522    f
4122    g
5345    h
I want my result data set to look like this:
Ex  CodeA   Field1  CodeB   Field2
1   2500    w   2525    b
1   2500    w   2522    f
2   4110    x   4113    c
3   2525    y   2525    b
4   5345    z   5345    h
 
     
    