<?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 Re: anonymizer function? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774418#M246133</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;&amp;nbsp;I guess the Viya version will be very relevant. Below two links I found which might give you some ideas.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=E6yVxbitC2k" target="_blank"&gt;https://www.youtube.com/watch?v=E6yVxbitC2k&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it's only about masking values in reports:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2018/03/02/is-it-sensitive-mask-it-with-data-suppression/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2018/03/02/is-it-sensitive-mask-it-with-data-suppression/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 02:48:28 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-10-15T02:48:28Z</dc:date>
    <item>
      <title>anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774300#M246081</link>
      <description>&lt;P&gt;I`ve written my own&amp;nbsp;anonymizer code, it works but I'm sure that in sas viya there must be an option or function for this purpose.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data casuser.test;
input codobjet $;
infile cards;
cards;
1372G2
1382NX
190901 
1T33AX 
210102 
260404 
2CAA94 
2CBT72 
2CJT94 
2EH1K5
;
run;

proc iml;

call randseed(123);
xx= randfun({4,6}, "integer", -20, 20);

print xx;

vary=repeat("a",4)||char(t(1:4));
vary2=catx("", vary[,1], vary[,2]);
 
do i=1 to 4;
temp=j(1,1, '                                                                                       ');
do j=1 to 6;
temp=catx(" ", temp, char(xx[i,j]));
end;
mac=choosec(i, "a1", "a2", "a3", "a4");
call symputx(mac, temp);
end;
quit;

%put &amp;amp;a3.;


data casuser.test2;
set casuser.test(obs=10);
array roll (6) _temporary_  (&amp;amp;a3.);
format chiffre inv_chiffre $12.;

do i=1 to length(codobjet);
chiffre=compress(catx("", chiffre, byte(rank(substr(codobjet, i, 1))+roll(i))));
end;

do j=1 to length(codobjet);
inv_chiffre=compress(catx("", inv_chiffre, byte(rank(substr(chiffre, j, 1))-roll(j))));
end;
keep codobjet chiffre inv_chiffre;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chiffre.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64723iEAEBA0475160B172/image-size/large?v=v2&amp;amp;px=999" role="button" title="chiffre.png" alt="chiffre.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 17:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774300#M246081</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-10-14T17:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774328#M246099</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to do anonymisation or pseudonymisation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want to do pseudonymisation (I haven't studied your code though) which often comes down to "string replacement".&lt;BR /&gt;&lt;BR /&gt;You can use the SHA256 algorithm to replace your identifiers (or other information) to unreadable-by-human 256-bit hash-values. SAS has a SHA256 Function!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want something human-readable (sometimes that is easier for testing and debugging) you can replace person / subject / object names by city names or by a combination of two words in a list of 100 names / flowers / rivers / colors / seas / mountains / first-names etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774328#M246099</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-10-14T19:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774341#M246103</link>
      <description>&lt;P&gt;Here is how we anonymize real data keys:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID_Anon = put(md5(cats('ID_ANON',ID),$hex10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can't decrypt this though so you need to keep a table of the real and anonymized keys. BTW the anonymized key is repeatable and unique so can be used for table joins etc.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 19:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774341#M246103</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-10-14T19:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774411#M246129</link>
      <description>&lt;P data-unlink="true"&gt;Isn't trimming to 5 characters (hex10.) out of 16 going to create collisions?&lt;/P&gt;
&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 01:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774411#M246129</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-15T01:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774412#M246130</link>
      <description>&lt;P&gt;Agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be $hex32. for a 128bit hash key. Any truncation will increase the collision risk which due to the birthday paradigm is always much higher than one would intuitively assume.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 02:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774412#M246130</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-15T02:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774418#M246133</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127222"&gt;@acordes&lt;/a&gt;&amp;nbsp;I guess the Viya version will be very relevant. Below two links I found which might give you some ideas.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=E6yVxbitC2k" target="_blank"&gt;https://www.youtube.com/watch?v=E6yVxbitC2k&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If it's only about masking values in reports:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2018/03/02/is-it-sensitive-mask-it-with-data-suppression/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2018/03/02/is-it-sensitive-mask-it-with-data-suppression/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 02:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774418#M246133</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-15T02:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774627#M246213</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp; - You are probably right. I was basing my example on a short key so should have considered the impact of longer ones.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 23:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774627#M246213</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-10-15T23:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: anonymizer function?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774638#M246219</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp; - You are probably right. I was basing my example on a short key so should have considered the impact of longer ones.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;The length of the key is of no relevance. It's just the number of rows / distinct source strings. I've even seen once in reality a collision happening with an "untruncated" md5() hash key which makes me now always consider using a sha256 instead of a md5 as soon as row numbers go into the millions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options ps=max;
data collisions;
  length id other_id 8 id_anon $10;
  dcl hash h1();
  h1.defineKey('ID_Anon');
  h1.defineData('other_id');
  h1.defineDone();

  do id=1 to 10**7;
    ID_Anon = put(md5(cats('ID_ANON',ID)),$hex10.);
    if h1.check()=0 then
      do;
        rc=h1.find();
        output;
        keep id other_id id_anon;
/*        leave;*/
      end;
    else
      do;
        other_id=id;
        rc=h1.add();
      end;
  end;

run;

proc print data=collisions;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Collisions if truncating to $hex10.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1634341484014.png" style="width: 178px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64772i65A95D3D3597BD9D/image-dimensions/178x636?v=v2" width="178" height="636" role="button" title="Patrick_0-1634341484014.png" alt="Patrick_0-1634341484014.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 23:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/anonymizer-function/m-p/774638#M246219</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-15T23:49:45Z</dc:date>
    </item>
  </channel>
</rss>

