Hi,
You can use Proc PWENCODE to encrypt
Syntax:
proc pwencode in='my password';
run;
Result Ex: {SAS002}DBCC571245AD0B31433834F80BD2B99E16B3C969
You have three examples:
1) The name John. What could that be changed into for example? What logic should it follow? Just 4 random letters?
2) Postal code should follow a certain pattern. This is hardly a masking task. What if it does not follow this pattern?
3) Same issue as (2).
For (2) and (3), take a look at Picture Formats. If you want a usable code answer, be more precise in your question.
Regards.
@Dontik wrote:
Hi
As stated in the title, how to mask/encrypt (using a certain pattern/set of rules) a column and be able to unmask/decrypt it later?
For example:
Name - needs to contains letters and no special characters like !@'j etc. So I would like to change a name like John to something that could possibly be a name, i.e. a set of letters.
Postal code - needs to follow a certain pattern NN-NNN, so 2 digits, a dash and 4 more digits.
Document numer - needs to follow a certain pattern LLNNNNN, so 2 letters and 5 digits. Masked value also needs to be unique.
But that's just the beginning, there should also be a way to reverse it, unmask it.
Any ideas?
Thank you in advance!
And WHERE is this to be masked?
If in output report pages then possibly formats could work. But if you want to limit other users of your data sets you may have significant issues if this is for security purposes.
I think you may be looking to make a series of formats but some issues arise such as is the data static or changing periodically. A one time use is not that difficult but details will arise if you will be continuing to add to the document number or postal codes.
Does the "name" masking need to create a "unique" value? How many characters? Minimum or Maximum length?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.