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!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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