Hi!
How can i update all columns in a table into hash join?
data master_table;
set master_table;
if _n_ = 1 then
do;
declare hash a (dataset:"update_table");
a.definekey('ID1','ID2');
a.definedone();
end;
if a.check() = 0 then
do;
/*??*/
end;
run;
Thanks!
I can't see your data, so this code is untested. But I think this is what you want
data master_table;
if _n_ = 1 then do;
declare hash a (dataset:"update_table");
a.definekey('ID1','ID2');
a.definedata(all : 'Y')
a.definedone();
end;
set master_table;
if 0 then set update_table;
rc = a.find();
run;
Whar do you mean by update? And to what values?
Where the 'update_table' table matches the 'master_table' key by key, overwrites all (non-key) fields with the field values in 'update_table'. (Both tables have the same fields.). Thanks!
I can't see your data, so this code is untested. But I think this is what you want
data master_table;
if _n_ = 1 then do;
declare hash a (dataset:"update_table");
a.definekey('ID1','ID2');
a.definedata(all : 'Y')
a.definedone();
end;
set master_table;
if 0 then set update_table;
rc = a.find();
run;
Also, if both tables contain exactly the same variables, then the if 0 .. statement is obsolete.
Thanks!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.