BookmarkSubscribeRSS Feed
buddha_d
Pyrite | Level 9

Dear Community,

           Good morning. I want to unhash these dummy SSNs data. Could you please give me suggestions? I have the following sample program.  I want to know how I can unhash the HASH_SSN variable in data two? 

Thanks in advance,

data one;

input ID :$ SSN $9. ;
CARDS;
SAM 567457869
SMITH 897845678
SONY 003457896
;
RUN;

DATA TWO;
	SET ONE;
HASH_SSN=upcase(put(sha256(strip(SSN)||"e8pZqXwS0R"),$hex64.)) ;
RUN;
2 REPLIES 2
LinusH
Tourmaline | Level 20

In a sense, hashing is some kind encryption. It's not meant to be reversed.

So before deciding to hashing values, you need to think of the consequences of doing so. Perhaps you need to store the original and hashed value pair somewhere (in a secure location if security is the reason to hash).

Data never sleeps
mkeintz
PROC Star

As @LinusH said, you can't reverse the hash code function.  If there were such a thing, what would be the point of the hash function in the first place?  It would no longer be providing any sort of privacy protection.

 

But if you have your population of ssn's somewhere, you could reapply the hash function to create a map between the encrypted and original values.  Then you could use that as a reverse lookup table.

 

 

 

 

--------------------------
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

--------------------------

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 1222 views
  • 0 likes
  • 3 in conversation