DATA Step, Macro, Functions and more

modify existing hash object

Reply
Contributor
Posts: 53

modify existing hash object

Hi, I am loading a hash table using a sas dataset. I need to modify the code so that only certain records are loaded. Am I correct in thinking that a hash iterator object is the way to go? Thanks in advance for your help.
Valued Guide
Posts: 632

Re: modify existing hash object

The ITERATOR object allows you to control the ordered retrieval of information from the hash table. Loading the table is much more straightforward. From your question it sounds like you will want to load the table one record at a time. The beauty of the hash object is that hash table is independent of the incoming order.

There are some references to information at:
http://www.sascommunity.org/wiki/Hash_object_resources
Respected Advisor
Posts: 3,887

Re: modify existing hash object

Hi

If this is only about subsetting a dataset before you load it into a hash object then why not creating a view and then using this view for loading the hash table, i.e.

proc sql;
create view HashInput as
select
from
where ;
quit;

data lookup;
set ....
if _n_ =1 then do;
declare hash h1 (dataset:'HashInput'<,...>);
....
end;
....
run;


If you have to modify the hash table while iterating through the data then look up the add() and delete() methods of the hash object.

HTH
Patrick
Ask a Question
Discussion stats
  • 2 replies
  • 162 views
  • 0 likes
  • 3 in conversation