Help using Base SAS procedures

Hash Merge in Data step

Reply
Contributor
Posts: 61

Hash Merge in Data step

Trying to determine the syntax for converting the following (simplified) process to a hash merge for speed purposes. Thanks!

data c;
merge a(in=ina keep = loan_no) b(in=inb keep=loan_no product);
by loan_no;
if ina;
run;

Should only keep loans in A and find the product in B....
Super Contributor
Super Contributor
Posts: 3,174

Re: Hash Merge in Data step

The SAS support http://support.sas.com/ website has several excellent technical / conference reference items on this topic.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

hash table merge site:sas.com
Super User
Posts: 3,106

Re: Hash Merge in Data step

Please note that a hash merge is not the only way to improve performance. A lookup SAS format created from your product table can also be a lot faster and simpler to code.The number of discrete loan numbers are you joining on should influence your chosen lookup technique. Be aware there are memory limitations with both hash tables and lookup formats.
Super User
Posts: 9,681

Re: Hash Merge in Data step

[pre]
data a(drop=rc);
declare hash hh(hashexp:10);
hh.definekey('loan_no');
hh.definedata('product');
hh.definedone();

do until(last);
set b( keep=loan_no product) end=last;
then hh.add();
end;

do until(_last);
set a(keep = loan_no) end=_last;
call missing(product);
rc=hh.find();
output;
end;
stop;
run;
[/pre]


Ksharp Message was edited by: Ksharp
Ask a Question
Discussion stats
  • 3 replies
  • 147 views
  • 0 likes
  • 4 in conversation