<?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: Apply $hex64 format but keep missing values empty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703031#M215383</link>
    <description>&lt;P&gt;Do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when ID ne ""
  then put(sha256(cat("XXX",ID)),$hex64.)
  else ""
end as hash_ID&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, in a data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hash;
set test;
length hash_id $64;
if id &amp;gt; "" then hash_id = put(sha256(cat("XXX",ID)),$hex64.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Dec 2020 08:53:45 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-12-02T08:53:45Z</dc:date>
    <item>
      <title>Apply $hex64 format but keep missing values empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703023#M215379</link>
      <description>&lt;P&gt;I create a hash for my ID variable with sha256 and apply the $hex64. format for readability. But when the ID is missing then it gets a hash value of 20202020... The receiver of my data will only receive the hash_ID, and I want to prevent they assume this ID was known and can be found by me,or that everyone with this hash is the same ID. Is there a way to get these missings to be displayed as missing also in the $hex64. format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input file ID $5.;
datalines;
1 02156
2 00369
3 45896
4 
5 78954
6 
7 78954
;
run;

proc sql;
create table hash as
select ID, 
		(case when ID ne "" then sha256(cat("XXX",ID)) else "" end) as hash_ID format = $hex64.
from test;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 08:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703023#M215379</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2020-12-02T08:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Apply $hex64 format but keep missing values empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703028#M215381</link>
      <description>&lt;P&gt;A good case for creating your own format, slightly different from hex&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input file ID $5.;
datalines;
1 02156
2 00369
3 45896
4 
5 78954
6 
7 78954
;
run;

proc format;
   value $ myhex
      ' '    = ' '
      other = [$hex64.]
   ;
run;

proc sql;
create table hash as
select ID, 
		(case when ID ne "" then sha256(cat("XXX",ID)) else "" end) as hash_ID format = $myhex.
from test;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ID     hash_ID 
02156  6098C1ED4949D1E7A4EA72C986640C40735CD5D1F201E9FC5DEE94435DE676F6 
00369  C79B09E1F340DCCC54FD1816BB9CD4A21C2AD7795674E5156784368C2EFB1A40 
45896  563FF6307A5DA67B9BBB3D383F6A12BCBDC54AEA03BFFB3358FDC1E6A75DDF6B 
	   
78954  F47211D85F84F5E03620727912C4382D601B064D52F3A8D2D38EDFD9B0DE5D7F 
	   
78954  F47211D85F84F5E03620727912C4382D601B064D52F3A8D2D38EDFD9B0DE5D7F &lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2020 08:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703028#M215381</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-02T08:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Apply $hex64 format but keep missing values empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703031#M215383</link>
      <description>&lt;P&gt;Do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when ID ne ""
  then put(sha256(cat("XXX",ID)),$hex64.)
  else ""
end as hash_ID&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, in a data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data hash;
set test;
length hash_id $64;
if id &amp;gt; "" then hash_id = put(sha256(cat("XXX",ID)),$hex64.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2020 08:53:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-hex64-format-but-keep-missing-values-empty/m-p/703031#M215383</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-02T08:53:45Z</dc:date>
    </item>
  </channel>
</rss>

