"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
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!
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
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: