Help using Base SAS procedures

masking data in sas dataset

Occasional Contributor
Posts: 12

masking data in sas dataset

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

Frequent Contributor
Posts: 79

Re: masking data in sas dataset

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

Super User
Posts: 10,784

Re: masking data in sas dataset

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 $;
Arthur 1234
Tom 1234
MikeZ 1234
Matt 1234

%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)) ;

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


Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation