BookmarkSubscribeRSS Feed
jaiganesh
Obsidian | Level 7

Hello,

 

 

Can anyone would help me with below concern.

 

"What is hashing algorithm in SAS?" , Can anyone explain with example.

 

 

Regards,

Jai

8 REPLIES 8
jaiganesh
Obsidian | Level 7

This question has been asked to me in one of the tough SAS interview.

andreas_lds
Jade | Level 19

@jaiganesh wrote:

This question has been asked to me in one of the tough SAS interview.


 

There are so many papers explaining hash-objects, i am sure they can be found using Google, Bing or any other search-site. You could, of course, just read the documentation provided at http://www.sas.com/store/books/categories/usage-and-reference/sas-hash-object-programming-made-easy/...

ChrisNZ
Tourmaline | Level 20

This question has been asked to me in one of the tough SAS interview.

 

This does not answer my question. Try to do some of the work yourself and then ask questions.

 

My reply would be another question: Do you mean the hashing function or the data set hash object?

Calling things by their proper name is always useful.

 

mkeintz
PROC Star

If you were asked about the "hashing algorithm" in SAS in an interview, then the interviewer does not know the meaning of their own question.

 

They could be asking about the MD5 or various SHA hashing functions, but I doubt it.  It's probably about the hash object, a tool exclusively available in the SAS data step.  It is very useful in particular for in-memory data lookup, data splitting, and aggregation, to mention a few.  I say "in-memory" because the hash object persists in SAS's memory as you read successive observations in a data step.  This persistence (think of it as a "retain" for a data table rather than for just a set of variables) makes it very useful in situations in which you need to read a particular data set more than once to generate the result data of interest.  Or perhaps you simply want to "lookup" data in one data set that correspond to a key found in another data set  (if the lookup data is accessed multiple times, it's faster to have it in memory than to be re-read from disk).

 

Aside from being an in-memory object, the hash object data lookup speed is faster than binary search methods.  That's because instead of applying the binary search to one big bucket of keys, the same search is applied to a much smaller specific one of (say) 256 mutually exclusive buckets of keys.  The trick is to (1) know which bucket to search, and (2) have buckets that contain roughly the same number of keys.  That's a property of some hashing functions (for all but the most pathological data), which underlie hash objects where the bucket collection is maintained.  As a user of hash objects you never see the underlying hash function - instead you store and retrieve data based on whatever set of keys (say ID variable  or ID/DATE combinations) that are relevant to your task.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
jaiganesh
Obsidian | Level 7
Let me read about the MD5 or various SHA hashing functions.
Ksharp
Super User

According to KEY value to find its/corresponding DATA value .

ScottBass
Rhodochrosite | Level 12

@jaiganesh wrote:

Hello,

 

 

Can anyone would help me with below concern.

 

"What is hashing algorithm in SAS?" , Can anyone explain with example.

 

 

Regards,

Jai


 

If by "anyone" you mean Google, then sure...

 

https://www.google.com/search?q=sas+hash+algorithm

 

Post back after you've read the first five links.

 

(In this instance, this will prepare you much better for your next interview than your original post and subsequent replies...)

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.

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
  • 8 replies
  • 1282 views
  • 5 likes
  • 6 in conversation