BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ger15xxhcker
Quartz | Level 8

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Whar do you mean by update? And to what values?

ger15xxhcker
Quartz | Level 8

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!

PeterClemmensen
Tourmaline | Level 20

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;
PeterClemmensen
Tourmaline | Level 20

Also, if both tables contain exactly the same variables, then the if 0 .. statement is obsolete. 

ger15xxhcker
Quartz | Level 8

Thanks!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1653 views
  • 1 like
  • 2 in conversation