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!
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!
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.