<?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: CATS function and buffer length in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111464#M23093</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi data _null_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for that. The only thing I needed to add was a strip() function as md5() uses the full variable length inclusive trailing blanks for calculation. Without strip() the digest values from the data step and the SQL would differ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;/P&gt;&lt;P&gt;&amp;nbsp; create table Has_Issues2(drop=vlist) as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(&amp;amp;varlist) as vlist length=1024,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(md5(strip(calculated vlist)),$hex32.) as DigestValue length=32&lt;/P&gt;&lt;P&gt;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't aware that I can use a calculated variable this way in a SAS SQL so that it's used immediately without any re-merging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given your answer I assume there is no way to actually increase buffer size for an intermediate cats() result. But then the nested function works in a data step so I'm still a bit confused about the different behavior of data step and SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Oct 2012 21:33:37 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2012-10-30T21:33:37Z</dc:date>
    <item>
      <title>CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111462#M23091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've run today into below problem (more than one OS and SAS version - below log from SAS 9.3 M2 under Win7).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I try do do is to calculate a digest value. The code used is very close to what DI Studio generates when using the SCD Type 2 loader. This digest value is used to determine if rows matched by a key differ in any of the variables used to construct the digest value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When having a lot of variables and using a data step everything works. But when using the exactly same nested functions in a SQL it returns a warning - and it actually does what the warning says: Not the full variable string is used to construct the digest value so the values differ between the data step version and the SQL version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't found a way around this issue. Any ideas of how to solve this? (eg. how to increase the buffer?).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an issue I've encountered during some "mocking around with code". So I'm not after a "work-around" but after a solution/explanation. It's more about getting a deeper understanding of what's going on here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; array vars {100} $10 (100*'abc');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;&amp;nbsp; select name into :varlist separated by ','&lt;BR /&gt;&amp;nbsp; from dictionary.columns&lt;BR /&gt;&amp;nbsp; where libname='WORK' and memname='HAVE'&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;/* returns a warning */&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table Has_Issues as&lt;BR /&gt;&amp;nbsp; select put(md5(cats(&amp;amp;varlist)),$hex32.) as DigestValue length=32&lt;BR /&gt;&amp;nbsp; from have&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;/* no warning. seems to work */&lt;BR /&gt;data No_Issues (drop=vars:);&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; length DigestValue $32.;&lt;BR /&gt;&amp;nbsp; DigestValue=put(md5(cats(&amp;amp;varlist)),$hex32.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOG:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table Has_Issues as&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select put(md5(cats(&amp;amp;varlist)),$hex32.) as DigestValue length=32&lt;/P&gt;&lt;P&gt;30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;31&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;WARNING: In a call to the CATS function, the buffer allocated for the result was not long enough to contain the concatenation of &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; all the arguments. The correct result would contain 300 characters, but the actual result might either be truncated to 200 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; argument that caused truncation.&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument 67 to function CATS. Missing values may be generated.&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.HAS_ISSUES created, with 1 rows and 1 columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 11:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111462#M23091</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-10-30T11:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111463#M23092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;sql&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; Has_Issues2(drop=vlist) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; cats(&amp;amp;varlist) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; vlist length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1024&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(md5(calculated vlist),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$hex32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; DigestValue length=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;32&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 11:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111463#M23092</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-10-30T11:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111464#M23093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi data _null_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for that. The only thing I needed to add was a strip() function as md5() uses the full variable length inclusive trailing blanks for calculation. Without strip() the digest values from the data step and the SQL would differ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; &lt;/P&gt;&lt;P&gt;&amp;nbsp; create table Has_Issues2(drop=vlist) as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select cats(&amp;amp;varlist) as vlist length=1024,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(md5(strip(calculated vlist)),$hex32.) as DigestValue length=32&lt;/P&gt;&lt;P&gt;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't aware that I can use a calculated variable this way in a SAS SQL so that it's used immediately without any re-merging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given your answer I assume there is no way to actually increase buffer size for an intermediate cats() result. But then the nested function works in a data step so I'm still a bit confused about the different behavior of data step and SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 21:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111464#M23093</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-10-30T21:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111465#M23094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Length of Returned Variable: Special Cases&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;The CATS function returns a value to a variable, or returns a value in a temporary buffer. The value that is returned from the CATS function has the following length: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;•up to 200 characters in WHERE clauses and in PROC SQL &lt;/P&gt;&lt;P&gt;•up to 32767 characters in the DATA step except in WHERE clauses &lt;/P&gt;&lt;P&gt;•up to 65534 characters when CATS is called from the macro processor &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2012 22:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111465#M23094</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-10-30T22:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111466#M23095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. Patrick.&lt;/P&gt;&lt;P&gt;"I assume there is no way to actually increase buffer size for an intermediate cats() result. But then the nested function works in a data step so I'm still a bit confused about the different behavior of data step and SQL."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Me, either.&lt;/P&gt;&lt;P&gt;I also am shocked that&amp;nbsp; cats() can worked in a data step, since is defaultly limited 200 long .&lt;/P&gt;&lt;P&gt;Or you can try to use another string concatenate operator ' || ' ,which has no such limitation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; array vars {100} $10 (100*'abc');
run;

proc sql noprint;
&amp;nbsp; select cats('strip(',name,')') into :varlist separated by '||'
&amp;nbsp; from dictionary.columns
&amp;nbsp; where libname='WORK' and memname='HAVE'
&amp;nbsp; ;
quit;



proc sql;
&amp;nbsp; create table Has_Issues as
&amp;nbsp; select put(md5(&amp;amp;varlist),$hex32.) as DigestValue length=32
&amp;nbsp; from have
&amp;nbsp; ;
quit;


data No_Issues (drop=vars:);
&amp;nbsp; set have;
&amp;nbsp; length DigestValue $32.;
&amp;nbsp; DigestValue=put(md5(&amp;amp;varlist),$hex32.);
run;
&lt;/PRE&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;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 06:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111466#M23095</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-10-31T06:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: CATS function and buffer length</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111467#M23096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested also. Without strip(), data step and sql is also matched.&lt;/P&gt;&lt;P&gt;The reason might be&amp;nbsp; in data step there is no limitation 200 for cats(), but for SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; array vars {100} $10 (100*'abc');
run;

proc sql noprint;
&amp;nbsp; select name into :varlist separated by '||'
&amp;nbsp; from dictionary.columns
&amp;nbsp; where libname='WORK' and memname='HAVE'
&amp;nbsp; ;
quit;



proc sql;
&amp;nbsp; create table Has_Issues as
&amp;nbsp; select put(md5(&amp;amp;varlist),$hex32.) as DigestValue length=32
&amp;nbsp; from have
&amp;nbsp; ;
quit;


data No_Issues (drop=vars:);
&amp;nbsp; set have;
&amp;nbsp; length DigestValue $32.;
&amp;nbsp; DigestValue=put(md5(&amp;amp;varlist),$hex32.);
run;

&lt;/PRE&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;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 06:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATS-function-and-buffer-length/m-p/111467#M23096</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-10-31T06:09:44Z</dc:date>
    </item>
  </channel>
</rss>

