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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.