Hi guys,
suppose to have the following dataset:
data DB1;
input ID :$20. ;
cards;
8
8
8
170
170
170
166
166
166
;
run;
and a list:
data DB2;
input ID :$20. ;
cards;
8
170
152
166
;
run;
Is there a way to match DB1 with DB2 and every time IDs of DB2 are found in DB1 a suffix "999" will be added?
Desired output:
data DB3;
input ID :$20. ;
cards;
8999
8999
8999
170999
170999
170999
166999
166999
166999
;
run;
Thank you in advance.
Best
data db3_test;
if 1=_N_ then
do;
declare hash h(dataset: "db2");
h.defineKey('ID');
h.defineDone();
end;
set db1;
if h.check()=0 then id = cats(id,'999');
run;
proc print;
run;
data db3_test;
if 1=_N_ then
do;
declare hash h(dataset: "db2");
h.defineKey('ID');
h.defineDone();
end;
set db1;
if h.check()=0 then id = cats(id,'999');
run;
proc print;
run;
According to your description this:
170999
170999
170999
should not exist in DB3.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.