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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 844 views
  • 0 likes
  • 3 in conversation