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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1131 views
  • 0 likes
  • 3 in conversation