Hi in table table1 and table2 i want to create table l3 from table1 and table2 tables based on table2.id2 =table.id
i want to do it on hash keys
data table1;
input id id2;
cards;
1 2
2 3
3 4
4 5
run;
data table2;
input id id2;
cards;
2 3
run;
output
id id2
3 4
Thqs Ksharp i know you will Reply
I can do same in joins
proc sql;
create table l3 as select a.id,a.id2 from table1 as a right join table2 as b
on a.id=b.id2;
quit;
proc print;run;
OK. Easy.
Assuming your id2 in table2 has no replicated value.
data table1;
input id id2;
cards;
1 2
2 3
3 4
4 5
;
run;
data table2;
input id id2;
cards;
2 3
;
run;
data want;
if _n_ eq 1 then do;
if 0 then set table2;
declare hash ha(dataset:'table2', hashexp:10);
ha.definekey('id2');
ha.definedone();
end;
set table1;
if ha.check(key:id)=0 then output;
run;
Ksharp
Thqs Ksharp i know you will Reply
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.