Could not get it to work with table1 as lookup. /* Dataset 1 */
DATA table1;
LENGTH pcode $ 8
xcode $ 2
bcode $ 2;
INFILE DATALINES DLM='|' DSD;
INPUT pcode $ xcode $ bcode $;
DATALINES;
00000001|03|A
00000002|03|B
00000003|04|C1
00000004|05|D2
00000005|05|D3 /* This value is not in table2, but needs to be added */
;
RUN;
/* Dataset 2 */
DATA table2;
LENGTH pcode $ 8
xcode $ 2
xcode_key $ 2
bcode $ 2
bcode_key $ 2;
INFILE DATALINES DLM='|' DSD;
INPUT pcode $ xcode $ xcode_key $ bcode $ bcode_key;
DATALINES;
00000001|03|10|A|5
00000002|03|10|B|10
00000003|04|20|C1|15
00000004|05|30|D2|20
00000007|05|42|XX|42 /* should not be in want-dataset */
;
RUN;
data want;
if 0 then set table2;
if _n_ = 1 then do;
declare hash h(dataset: "table2");
h.defineKey("pcode", "xcode", "bcode");
/*h.defineData(all: "yes"); no need to define data-elements */
h.defineDone();
end;
set table1;
CODE_FOUND = ifc(h.check() = 0, "T", "F");
run;
... View more