<?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: re: Catx Function Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229933#M41649</link>
    <description>&lt;P&gt;Hi, you can determine the length you need in a data step ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* fake data;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data transpose;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;retain col1-col100 1234;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;col100 = 12345678901234567890; output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;col100 = 1; output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;set transpose end=last;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ll + max(ll, length(catx(':', of col: ))) - ll;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;if last then call symputx('length',ll);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* use macro variable, no array;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data want (keep=xyz);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;length xyz $&amp;amp;length.;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;set transpose;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;xyz = catx(':', of col: );&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;PROC CONTENTS ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Alphabetic List of Variables and Attributes&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; Variable&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&amp;nbsp;&amp;nbsp;&amp;nbsp; Len&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Char&amp;nbsp;&amp;nbsp;&amp;nbsp; 515&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2015 20:10:37 GMT</pubDate>
    <dc:creator>MikeZdeb</dc:creator>
    <dc:date>2015-10-14T20:10:37Z</dc:date>
    <item>
      <title>re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229882#M41638</link>
      <description>&lt;P&gt;Hi....I am using the Catx Function in a data step and get warning message. The code and warning message are as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WANT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET TRANSPOSED;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARRAY c col: ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;FINAL = catx(' : ', of c(*));&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: In a call to the CATX function, the buffer allocated for the result was not &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long enough to contain the concatenation of all the arguments. The correct &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result would contain 262 characters, but the actual result may either be &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncated to 200 character(s) or be completely blank, depending on the calling &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; environment. The following note indicates the left-most argument that caused &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 13:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229882#M41638</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2015-10-14T13:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229884#M41639</link>
      <description>&lt;P&gt;The error is always appreciated but to get a more complete answer I recommend adding the data you have and the data you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So give an example dataset 'transposed'&amp;nbsp; and 'want'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 13:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229884#M41639</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-10-14T13:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229895#M41641</link>
      <description>&lt;P&gt;Per default variable "FINAL" gets a length of $200. This appears to be too short to hold the result of your catx() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assign an appropriate length to "FINAL" and things will work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT;
     SET TRANSPOSED;
     ARRAY c col: ;
     length FINAL $262;
      FINAL = catx(' : ', of c(*));
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Oct 2015 13:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229895#M41641</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-10-14T13:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229905#M41644</link>
      <description>&lt;P&gt;Hi Patrick.....thanks for you help. I did try including the Length Statement and I get the following warning mesaage:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: In a call to the CATX function, the buffer allocated for the result was not &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; long enough to contain the concatenation of all the arguments. The correct &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result would contain 327 characters, but the actual result may either be &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncated to 262 character(s) or be completely blank, depending on the calling &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; environment. The following note indicates the left-most argument that caused &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; truncation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did try using the compress function and the error message was gone but I don't want to remove blanks.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 14:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229905#M41644</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2015-10-14T14:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229918#M41646</link>
      <description>&lt;P&gt;Looks like you need to know your data. You need to set the length of the target variable large enough to take the longest string it will generate. So SUM the DEFINED lengths of all of the C:&amp;nbsp;variables and the number of characters that will be inserted for the delimiter by CATX and that would be a minimum.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 15:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229918#M41646</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-14T15:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: re: Catx Function Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229933#M41649</link>
      <description>&lt;P&gt;Hi, you can determine the length you need in a data step ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* fake data;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data transpose;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;retain col1-col100 1234;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;col100 = 12345678901234567890; output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;col100 = 1; output;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data _null_;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;set transpose end=last;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ll + max(ll, length(catx(':', of col: ))) - ll;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;if last then call symputx('length',ll);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;* use macro variable, no array;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data want (keep=xyz);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;length xyz $&amp;amp;length.;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;set transpose;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;xyz = catx(':', of col: );&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;PROC CONTENTS ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Alphabetic List of Variables and Attributes&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; Variable&amp;nbsp;&amp;nbsp;&amp;nbsp; Type&amp;nbsp;&amp;nbsp;&amp;nbsp; Len&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Char&amp;nbsp;&amp;nbsp;&amp;nbsp; 515&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 20:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Catx-Function-Error/m-p/229933#M41649</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-10-14T20:10:37Z</dc:date>
    </item>
  </channel>
</rss>

