BookmarkSubscribeRSS Feed
Haikuo
Onyx | Level 15

"The purpose for it in your example is to only create and load the hash table once, at the start of the first loop through the step. It only needs to be done once."

Agreed.

"If you removed this check the hash table would be created and loaded for every record the step is processing!"

Hmmmm, not always. It depends heavily on your data step construct. There are constructs within which loops just once but output multiple records(eg. output()), or loops a lot less than the records it outputs or processes, eg. wrap up 'set' statement with DOW.

So to use _n_=1 loop is more of a better practice and saft guard issue.

Regards,

Haikuo

SASKiwi
PROC Star

Cheers Haikuo. My comments were based just on the code as it stands. Of course if you change it with your own looping code then you could avoid loading the hash table for every record by another method. Just trying to keep it simple!

Haikuo
Onyx | Level 15

Hi SASkiwi,

There is NOT a second that I have questioned your or others' understanding of Hash. However, Given that OP is obviously new to Hash, I choose this  complex way to unfold more aspects in front him/her. It seems more purplex up front, but hopefully will help him with the big picture further down the road.

Regards,

Haikuo

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 17 replies
  • 35984 views
  • 11 likes
  • 8 in conversation