BookmarkSubscribeRSS Feed
frisco
Calcite | Level 5
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.
2 REPLIES 2
ArtC
Rhodochrosite | Level 12
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
Patrick
Opal | Level 21
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1640 views
  • 0 likes
  • 3 in conversation