<?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: CATX function buffer always truncated to 16 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446273#M111951</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I try to change length in proc sql like:&lt;/P&gt;
&lt;P&gt;t1.New format=$100.,&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Changing the format attached to a variable does NOT change the length.&amp;nbsp; If you want to set the LENGTH then use LENGTH= option instead. Note that in an SQL SELECT statement the value of the LENGTH= does not include the $ prefix for character variables as it does in the normal LENGTH statement you would use in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table newtable as
  select a,b,c,catx('_',a,b,c) as new length=100 
  from oldtable
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Mar 2018 17:27:54 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-03-16T17:27:54Z</dc:date>
    <item>
      <title>CATX function buffer always truncated to 16</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446222#M111926</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I try to do this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update WORK.List
set New= catx('-', put(substr(New, 7, 4), $4.), put(datepart(Date), yymmdd10.), Name)
  , Name=case when Name LIKE '%NOVA' then substr(Name, 1, length(Name)-4) end
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;In a call to the CATX function, the buffer allocated for the result was not long enough to contain the concatenation of 
         all the arguments. The correct result would contain 30 characters, but the actual result might either be truncated to 16 
         character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most 
         argument that caused truncation.
WARNING: In a call to the CATX function, the buffer allocated for the result was not long enough to contain the concatenation of 
2                                                          The SAS System                               14:03 Friday, March 16, 2018

         all the arguments. The correct result would contain 35 characters, but the actual result might either be truncated to 16 
         character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most 
         argument that caused truncation.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result is a column in blanks, not the string truncated to 16, i don't understand what means calling environment to be completely blank.&lt;/P&gt;
&lt;P&gt;I try to change length in proc sql like:&lt;/P&gt;
&lt;P&gt;t1.New format=$100.,&amp;nbsp; but always same error. I think is because de limitation of buffer in catx.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How i can solve this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Aleixo&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>Fri, 16 Mar 2018 17:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446222#M111926</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-16T17:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: CATX function buffer always truncated to 16</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446247#M111937</link>
      <description>&lt;P&gt;Since I see this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="token keyword"&gt;update&lt;/SPAN&gt; WORK&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;List&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;then that means that the variable NEW already exists in your data set. It probably has a length of 16 which is not likely to change with an UPDATE which means "change in place"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try creating a new table..&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>Fri, 16 Mar 2018 16:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446247#M111937</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-16T16:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: CATX function buffer always truncated to 16</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446273#M111951</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I try to change length in proc sql like:&lt;/P&gt;
&lt;P&gt;t1.New format=$100.,&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Changing the format attached to a variable does NOT change the length.&amp;nbsp; If you want to set the LENGTH then use LENGTH= option instead. Note that in an SQL SELECT statement the value of the LENGTH= does not include the $ prefix for character variables as it does in the normal LENGTH statement you would use in a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table newtable as
  select a,b,c,catx('_',a,b,c) as new length=100 
  from oldtable
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 17:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446273#M111951</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-16T17:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: CATX function buffer always truncated to 16</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446282#M111952</link>
      <description>&lt;P&gt;If you want more control over which 16 characters from your concatenated string are stored into the 16 character long variable NEW you could add a SUBSTR() function call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update WORK.List
set New= substr(catx('-', substr(New, 7, 4), put(datepart(Date), yymmdd10.), Name),1,16)
  , Name=case when Name LIKE '%NOVA' then substr(Name, 1, length(Name)-4) end
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note there is no need to use PUT() around the substr() function you had before.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 17:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446282#M111952</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-16T17:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: CATX function buffer always truncated to 16</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446700#M112121</link>
      <description>&lt;P&gt;Thank you very much all answers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom i think is update statement you will update all observations. We have to add a else statement to update only the observations that you want. Am i right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;aleixo&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 09:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CATX-function-buffer-always-truncated-to-16/m-p/446700#M112121</guid>
      <dc:creator>Aleixo</dc:creator>
      <dc:date>2018-03-19T09:20:26Z</dc:date>
    </item>
  </channel>
</rss>

