* Hash sample - read and sort raw data;
data _null_;
/* Declare hash object and key and data variable names */
if _N_ = 1 then do;
declare hash h(ordered:'A');
rc = h.defineKey('key');
rc = h.defineData('key','value');
rc = h.defineDone();
end;
/* Read key and data values */
infile datalines eof=eof;
input key value $;
/* Add key and data values to hash object */
rc = h.add();
return;
eof: rc = h.output(dataset:"ordered");
cards;
1 value1
3 value2
2 value3
;
Actually, it is only one little tip of Hash object.
We must never forget that the main functionality of Hash object is to quickly and efficiently store, search, and retrieve data based on lookup keys.
No comments:
Post a Comment