BookmarkSubscribeRSS Feed
mvk_sas
Calcite | Level 5

Hi All,

I would appreciate if someone could help in masking data in sas dataset.

Example:  I have sas dataset like below

Customer_name  Customer_ID

John                    12345

Mke                     12346

I wanted mask one column in this say customer_name. how can we do that. In case if we encrypt the data is there a way to decrept also.

Thanks in advance... MVK

2 REPLIES 2
robby_beum
Quartz | Level 8

FriedEgg had posted a discussion about data masking and implementing a cipher:

https://communities.sas.com/message/106874#106874

Ksharp
Super User

There are lots of algorithm for encoding and decoding .

I pick up the most simple one .It is from JavaEE Tutorial 6 .

The implementation of codeString in CoderImpl shifts the string argument forward in the alphabet

by the number of letters specified in the second argument; any characters that are not letters are

left unchanged. (This simple shift code is known as a Caesar cipher, for Julius Caesar, who

reportedly used it to communicate with his generals.)

I took offset as 4 .

data have;
input name $ id $;
cards;
Arthur 1234
Tom 1234
MikeZ 1234
Matt 1234
;
run;


%let offset=4;
data encode;
 set have;
 do _n_=1 to length(name);
 substr(name,_n_,1) = byte(mod(rank(char(name,_n_))+&offset,255)) ;
 end;
run;

data decode;
 set encode;
 do _n_=1 to length(name);
 substr(name,_n_,1) =byte(mod(rank(char(name,_n_))-&offset+255,255));
 end;
run;





Ksharp

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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