<?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: MD5 with cats function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682057#M206430</link>
    <description>&lt;P&gt;You didn't answer my question. In the log, are you getting the below warning (or a similar warning)?&lt;/P&gt;
&lt;PRE&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough
         to contain the concatenation of all the arguments. The correct result would contain
         32768 characters, but the actual result might either be truncated to 32767 character(s)
         or be completely blank, depending on the calling environment. The following note
         indicates the left-most argument that caused truncation.&lt;/PRE&gt;
&lt;P&gt;Can you post your log?&lt;/P&gt;</description>
    <pubDate>Mon, 07 Sep 2020 18:56:38 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2020-09-07T18:56:38Z</dc:date>
    <item>
      <title>MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680909#M205899</link>
      <description>&lt;P&gt;Good day&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a md5 macro that concatenates variables which I call later on,however the lenght is kept at 200, i would like to know how extend the lenght here is the sample code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro md5_concatenate_mydata();&lt;BR /&gt;md5(&lt;BR /&gt;cats(&lt;BR /&gt;ACCOUNT_NUMBER,'|',&lt;/P&gt;&lt;P&gt;put(balance, best32.)&amp;nbsp;&amp;nbsp;,'|',&lt;/P&gt;&lt;P&gt;status&amp;nbsp;,'|',&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;%mend md5_concatenate_mydata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;say up to 50 variables, now i call it in a data step, it only&amp;nbsp; keeps 200 characters not more when i call it&lt;/P&gt;&lt;P&gt;how can i format it to go beyond 200 in lenght? as it is based on concatination of the md5 macro above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro hashtables( i_hashFunction=, i_table=, i_primaryKey= );&lt;/P&gt;&lt;P&gt;data work.data_want (keep = account_number md5 );&lt;BR /&gt;set&amp;nbsp; &amp;amp;i_table;&lt;/P&gt;&lt;P&gt;md5 = %&amp;amp;i_hashFunction.();&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend hashtables;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%hashtables(&lt;BR /&gt;i_hashFunction = md5_concatenate_mydata,&lt;BR /&gt;i_table = data_want.,&lt;BR /&gt;i_primarykey = ACCOUNT_NUMBER );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 10:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680909#M205899</guid>
      <dc:creator>langalife</dc:creator>
      <dc:date>2020-09-02T10:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680911#M205900</link>
      <description>&lt;P&gt;Have a look at the documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;In a DATA step, if the CATS function returns a value to a variable that has not previously been assigned a length, that variable is given a length of 200 bytes.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 02 Sep 2020 10:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680911#M205900</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-02T10:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680914#M205901</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;i had a look at documentation, it didnt help.&lt;/P&gt;&lt;P&gt;if that was a variable it was going to be easy for me to change.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 10:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680914#M205901</guid>
      <dc:creator>langalife</dc:creator>
      <dc:date>2020-09-02T10:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680939#M205913</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293682"&gt;@langalife&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i had a look at documentation, it didnt help.&lt;/P&gt;
&lt;P&gt;if that was a variable it was going to be easy for me to change.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;ok. back to square one: i would try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.data_want (keep = account_number md5 );
  set  &amp;amp;i_table;
  length allVars $ 1000;
  allVars = cats(list_vars_skipping_separating_chars_and_formats);
  md5 = md5(allVars);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Sep 2020 12:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680939#M205913</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-02T12:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680969#M205930</link>
      <description>&lt;P&gt;I'm confused.&amp;nbsp; In the DATA step (outside of a WHERE statement) the buffer for CATS should be 32,767 per the docs:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below test seems to confirm this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  retain x1-x33000 'X' ;
run ;

data want0;
  set  have;
  md5 = md5(cats(of x1-x32767));
run;

data want1;
  set  have;
  md5 = md5(cats(of x1-x32768));
run;

data want2;
  set  have;
  md5 = md5(cats(of x1-x32769));
run;

proc compare base=want0 compare=want1 ;
run ;

proc compare base=want1 compare=want2 ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you think your real data exceed the 32,767 limit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the log, are you getting the warning:&lt;/P&gt;
&lt;PRE&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough
         to contain the concatenation of all the arguments. The correct result would contain
         32768 characters, but the actual result might either be truncated to 32767 character(s)
         or be completely blank, depending on the calling environment. The following note
         indicates the left-most argument that caused truncation.
&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Sep 2020 13:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/680969#M205930</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-09-02T13:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681021#M205938</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293682"&gt;@langalife&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps I'm missing something, but have you tried adding a length in your Data step to the md5 variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.data_want (keep = account_number md5 );
     LENGTH md5 $32767;
     set  &amp;amp;i_table;

     md5 = %&amp;amp;i_hashFunction.();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If md5 is already defined in the data coming in via the Set statement, you may have to either modify the dataset or rename the variable (using the RENAME option on the Set statement) to some new name, say "temp_md5",&amp;nbsp; and then move the value of temp_md5 to md5, i.e.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;md5 = temp_md5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 14:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681021#M205938</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-02T14:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681071#M205958</link>
      <description>&lt;P&gt;Rules vary for CAT depending on where it's being used.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-paragraph"&gt;The CATX function returns a value to a variable or returns a value in a temporary buffer. The value that is returned from the CATX function has one of these lengths:&lt;/P&gt;
&lt;UL class="xisDoc-listUnordered"&gt;
&lt;LI class="xisDoc-item"&gt;&lt;STRONG&gt;up to 200 characters in WHERE clauses and in PROC SQL&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI class="xisDoc-item"&gt;up to 32767 characters in the DATA step, except in WHERE clauses&lt;/LI&gt;
&lt;LI class="xisDoc-item"&gt;up to 65534 characters when CATX is called from the macro processor&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;FYI - it looks like you're actually building a function, could PROC FCMP be used here instead? it's a slightly cleaner approach.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 16:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681071#M205958</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-02T16:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681329#M206068</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;.  In the OP's example, %hashtables, they're using it in DATA step outside of a where clause, which is why I said they should be getting the full 32,767 characters.  But if IRL they're using on a WHERE clause, that would explain why they're getting so much truncation.  And I agree,  likely FCMP could be a better route.</description>
      <pubDate>Thu, 03 Sep 2020 13:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/681329#M206068</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-09-03T13:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682020#M206411</link>
      <description>&lt;P&gt;Upto so far i havent found a posted solution.&lt;/P&gt;&lt;P&gt;I use the cats function inside md5, example is as shown below.&lt;/P&gt;&lt;P&gt;%macro hashtables( i_hashFunction=, i_table=, i_primaryKey= );&lt;/P&gt;&lt;P&gt;data work.data_want (keep = account_number md5 );&lt;BR /&gt;set&amp;nbsp; &amp;amp;i_table;&lt;/P&gt;&lt;P&gt;md5 =&amp;nbsp;&lt;/P&gt;&lt;P&gt;md5(&lt;BR /&gt;cats(&lt;BR /&gt;ACCOUNT_NUMBER,'|',&lt;/P&gt;&lt;P&gt;put(balance, best32.)&amp;nbsp;&amp;nbsp;,'|',&lt;/P&gt;&lt;P&gt;status&amp;nbsp;,'|',&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend hashtables;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%hashtables(&lt;BR /&gt;i_table = data_want.,&lt;BR /&gt;i_primarykey = ACCOUNT_NUMBER );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 13:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682020#M206411</guid>
      <dc:creator>langalife</dc:creator>
      <dc:date>2020-09-07T13:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682057#M206430</link>
      <description>&lt;P&gt;You didn't answer my question. In the log, are you getting the below warning (or a similar warning)?&lt;/P&gt;
&lt;PRE&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough
         to contain the concatenation of all the arguments. The correct result would contain
         32768 characters, but the actual result might either be truncated to 32767 character(s)
         or be completely blank, depending on the calling environment. The following note
         indicates the left-most argument that caused truncation.&lt;/PRE&gt;
&lt;P&gt;Can you post your log?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 18:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682057#M206430</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-09-07T18:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682098#M206454</link>
      <description>&lt;P&gt;Adding the put function should lengthen your variable (untested):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro md5_concatenate_mydata();
  put(md5(catx( '|'
              , ACCOUNT_NUMBER
              , put(BALANCE, best32.)  
              , STATUS
              ,
              ,
     )), $32000.);
%mend md5_concatenate_mydata;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 21:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682098#M206454</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-09T21:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: MD5 with cats function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682778#M206702</link>
      <description>&lt;P&gt;Note that MD5 is now considered insecure, and that SHA256 is to be preferred.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 21:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MD5-with-cats-function/m-p/682778#M206702</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-09T21:16:39Z</dc:date>
    </item>
  </channel>
</rss>

