BookmarkSubscribeRSS Feed
Monty82
Calcite | Level 5

Hi there,

 

somebody hashed account number using the SQL code: 'SHA2_256' . Is there a SAS equivalent function to give the same hashed account? I used SHA256 but no luck yet.

 

Your help will be highly appreciated.

 

many thanks,

4 REPLIES 4
LinusH
Tourmaline | Level 20

As I understand it, SAS uses the "global" available algorithm. So it shouldn't be any difference.

How did you verify that didn't have any luck?

Perhaps it's the data that changed between the environments. Transcoding/truncation of trailing blanks etc can occur.

Data never sleeps
Monty82
Calcite | Level 5
Thanks for your help. I found out what my issue was. Hashing variable from numeric and character give different values. Thanks for that.
FriedEgg
SAS Employee

The output of the SHA256 function in SAS is the raw bytes.  I assume you want the hash string.  In which case you just want to combine the SHA256 function call with a PUT function and the $hex64. format.  Without specifying what SQL implementation you are referring to, I can only speculate what you are really looking for.

 

data foo;
set sashelp.class;
hash_name=put(sha256(name),$hex64.);
run;
Monty82
Calcite | Level 5
Thanks for your help. I found out what my issue was. Hashing variable from numeric and character give different values. Yes, I used the same code as you mentioned. Thanks for that.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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