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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 17 replies
  • 35321 views
  • 11 likes
  • 8 in conversation