<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to interchange character position for masking purpose in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651735#M22416</link>
    <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a query on how to dynamically interchange the position of a character variable in a way that receiver of my file can re-generate the original values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Input and Output is as follows:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Input&lt;/TD&gt;&lt;TD&gt;Output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;Lhameci&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;A href="mailto:Jack@gmail.com" target="_blank" rel="noopener"&gt;Jack@gmail.com&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:kcja@gmail.com" target="_blank" rel="noopener"&gt;kcja@gmail.com&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AO987JJ&lt;/TD&gt;&lt;TD&gt;9J78JOA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9650234567&lt;/TD&gt;&lt;TD&gt;6953035947&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 May 2020 14:19:30 GMT</pubDate>
    <dc:creator>Trishjais</dc:creator>
    <dc:date>2020-05-29T14:19:30Z</dc:date>
    <item>
      <title>how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651735#M22416</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a query on how to dynamically interchange the position of a character variable in a way that receiver of my file can re-generate the original values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Input and Output is as follows:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Input&lt;/TD&gt;&lt;TD&gt;Output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;Lhameci&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;A href="mailto:Jack@gmail.com" target="_blank" rel="noopener"&gt;Jack@gmail.com&lt;/A&gt;&lt;/TD&gt;&lt;TD&gt;&lt;A href="mailto:kcja@gmail.com" target="_blank" rel="noopener"&gt;kcja@gmail.com&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AO987JJ&lt;/TD&gt;&lt;TD&gt;9J78JOA&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9650234567&lt;/TD&gt;&lt;TD&gt;6953035947&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 14:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651735#M22416</guid>
      <dc:creator>Trishjais</dc:creator>
      <dc:date>2020-05-29T14:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651853#M22426</link>
      <description>&lt;P&gt;How many other exceptions to scrambling the entire string do you have? And what do they look like if they are not email addresses?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a random approach?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And where did the second J go in your third example? If characters are to be substituted you need to state any rules involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you expect the other person to use this?&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 19:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651853#M22426</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-29T19:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651870#M22428</link>
      <description>Hello&lt;BR /&gt;There could be only 4 types, mobile number, email addresses, ID type(SSN),Full Name.&lt;BR /&gt;I want to just change the position of character on the basis of length of each variable. For eg JACK has length of 4 so the receiver of my file will re-arrange the characters to get JACK, similarly for email addresses any character before @ should be interchanged.</description>
      <pubDate>Fri, 29 May 2020 20:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651870#M22428</guid>
      <dc:creator>Trishjais</dc:creator>
      <dc:date>2020-05-29T20:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651894#M22429</link>
      <description>&lt;P&gt;What is your actual business problem? Also interchanging character positions isn't masking, it is a very basic form of encryption. If you simply want to exchange data with other parties in encrypted form, why not just use an encryption tool? It is so much easier than doing what you are suggesting and a whole lot more secure too.&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 23:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651894#M22429</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-05-29T23:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651912#M22431</link>
      <description>&lt;P&gt;You can permute the string characters following a random sequence set by a secret seed, and then reverse the permutation using the same seed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input InputStr :$20.;
datalines; 
Michael
Jack@gmail.com
AO987JJ
9650234567
;

%let seed=736435; /* Secret code */

/* Blurring the strings */
data blur;
retain seed &amp;amp;seed.;
set have;
isEmail = index(InputStr, "@") &amp;gt; 1;
length str $20;
if isEmail then str = scan(InputStr,1,"@");
    else str = InputStr;
isName = str = propCase(str);

array pos{20};
do i = 1 to length(str);
    pos{i} = i;
    end;
  
/* Could be coded with a macro I guess, to accomodate longer strings ... */
select (length(str));
when ( 2) call ranperm(seed, of pos1-pos2);
when ( 3) call ranperm(seed, of pos1-pos3);
when ( 4) call ranperm(seed, of pos1-pos4);
when ( 5) call ranperm(seed, of pos1-pos5);
when ( 6) call ranperm(seed, of pos1-pos6);
when ( 7) call ranperm(seed, of pos1-pos7);
when ( 8) call ranperm(seed, of pos1-pos8);
when ( 9) call ranperm(seed, of pos1-pos9);
when (10) call ranperm(seed, of pos1-pos10);
when (11) call ranperm(seed, of pos1-pos11);
when (12) call ranperm(seed, of pos1-pos12);
when (13) call ranperm(seed, of pos1-pos13);
when (14) call ranperm(seed, of pos1-pos14);
when (15) call ranperm(seed, of pos1-pos15);
when (16) call ranperm(seed, of pos1-pos16);
when (17) call ranperm(seed, of pos1-pos17);
when (18) call ranperm(seed, of pos1-pos18);
when (19) call ranperm(seed, of pos1-pos19);
when (20) call ranperm(seed, of pos1-pos20);
otherwise;
end;

length OutputStr $20;
do i = 1 to length(str);
    substr(outputStr, i, 1) = substr(str, pos{i}, 1);
    end;
    
if isName then OutputStr = propCase(OutputStr);
if isEmail then OutputStr = catx("@", OutputStr, scan(InputStr, 2, "@"));
drop i seed isName isEmail str pos:;
run;

/* Recovering the strings, using the same secret code */
data want;
retain seed &amp;amp;seed.;
set blur;
isEmail = index(OutputStr, "@") &amp;gt; 1;
length str $20;
if isEmail then str = scan(OutputStr,1,"@");
    else str = OutputStr;
isName = str = propCase(str);

array pos{20};
do i = 1 to length(str);
    pos{i} = i;
    end;
  
select (length(str));
when ( 2) call ranperm(seed, of pos1-pos2);
when ( 3) call ranperm(seed, of pos1-pos3);
when ( 4) call ranperm(seed, of pos1-pos4);
when ( 5) call ranperm(seed, of pos1-pos5);
when ( 6) call ranperm(seed, of pos1-pos6);
when ( 7) call ranperm(seed, of pos1-pos7);
when ( 8) call ranperm(seed, of pos1-pos8);
when ( 9) call ranperm(seed, of pos1-pos9);
when (10) call ranperm(seed, of pos1-pos10);
when (11) call ranperm(seed, of pos1-pos11);
when (12) call ranperm(seed, of pos1-pos12);
when (13) call ranperm(seed, of pos1-pos13);
when (14) call ranperm(seed, of pos1-pos14);
when (15) call ranperm(seed, of pos1-pos15);
when (16) call ranperm(seed, of pos1-pos16);
when (17) call ranperm(seed, of pos1-pos17);
when (18) call ranperm(seed, of pos1-pos18);
when (19) call ranperm(seed, of pos1-pos19);
when (20) call ranperm(seed, of pos1-pos20);
otherwise;
end;

length SecretStr $20;
do i = 1 to length(str);
    substr(SecretStr, pos{i}, 1) = substr(str, i, 1);
    end;
    
if isName then SecretStr = propCase(SecretStr);
if isEmail then SecretStr = catx("@", SecretStr, scan(OutputStr, 2, "@"));
drop i seed isName isEmail str pos:;
run;

title "Blurred and deblurred strings";
proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;            Blurred and deblurred strings
Obs. 	InputStr 	OutputStr 	SecretStr
1 	Michael 	Acemhil 	Michael
2 	Jack@gmail.com 	Cjak@gmail.com 	Jack@gmail.com
3 	AO987JJ 	78AO9JJ 	AO987JJ
4 	9650234567 	4620673559 	9650234567&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 May 2020 03:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651912#M22431</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-30T03:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to interchange character position for masking purpose</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651922#M22432</link>
      <description>Thank . It was really helpful.</description>
      <pubDate>Sat, 30 May 2020 04:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-interchange-character-position-for-masking-purpose/m-p/651922#M22432</guid>
      <dc:creator>Trishjais</dc:creator>
      <dc:date>2020-05-30T04:08:48Z</dc:date>
    </item>
  </channel>
</rss>

