<?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: Concat with catx don't works because  to large string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936186#M368016</link>
    <description>&lt;P&gt;Related threads combined.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2024 14:46:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-07-18T14:46:10Z</dc:date>
    <item>
      <title>Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936178#M368008</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to concat 3 columns but the content are to large, in the final concat i got blank.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Exemple : columns A , B, C =&amp;gt; after concat ; var full = A;B;C&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i just got Blank,&amp;nbsp;&lt;/P&gt;&lt;P&gt;if B and C are empty i get A, because not to large&lt;/P&gt;&lt;P&gt;but if A, B, C are not empty i get Blank. because to large string inside.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code :&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.amel;&lt;BR /&gt;set work.consoli;&lt;BR /&gt;full = catx(";", A,B,C);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 13:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936178#M368008</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T13:45:23Z</dc:date>
    </item>
    <item>
      <title>Concat with catx don't works because  to large string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936157#M368014</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm trying to concatenate 3 columns separated by commas but the final result: full displays nothing it's totally empty because the text is too large&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;example: varA&lt;BR /&gt;“stringA............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................stringA ”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in varB i have :&lt;/P&gt;&lt;P&gt;"stringB............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................stringB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in varC :&lt;BR /&gt;"stringC............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................stringC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;after concat I must have var full = varA;varB;varC&lt;/P&gt;&lt;P&gt;with long texts separated by commas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mycode :&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.amel;&lt;BR /&gt;set work.consoli;&lt;BR /&gt;full = catx(";",A,B,C);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got blank&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 12:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936157#M368014</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T12:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936181#M368010</link>
      <description>&lt;P&gt;From now on, when you are getting errors, please show us the log for the DATA step or PROC with the errors, including the code as it appears in the log and all ERRORs, WARNINGs and NOTEs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need a LENGTH statement in your DATA step, before you try to create FULL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length full $ 32;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where the 32 should be replaced by some other number that represents the max length of the resulting string.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936181#M368010</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-18T14:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works because  to large string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936182#M368015</link>
      <description>&lt;P&gt;I would verify each of your assumptions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Confirm that work.consoli actually contains A, B, and C:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=work.consoli;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Next, confirm that A, B, and C contain data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=work.consoli (obs=1);
var a b c;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will probably clarify what needs to change, but try it and see.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936182#M368015</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-07-18T14:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936183#M368012</link>
      <description>&lt;P&gt;What are the defined lengths of your variables A, B and C? Did the LOG show any notes or warnings? If so, copy the text of the LOG, open a text box window on the forum and paste the text of the log for the data step with all of the notes or other messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not know the lengths of your variables then run:&lt;/P&gt;
&lt;PRE&gt;proc contents data=work.consoli;
run;&lt;/PRE&gt;
&lt;P&gt;to show the properties of the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you do not provide a defined length for the variable FULL then it will get a length of 200 which may result in truncated values if the variables combined are "long".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a best practice to assign a length to new character variables before use. In your example the length should be the total of the lengths of the variables A, B and C &lt;STRONG&gt;plus&lt;/STRONG&gt; 2 to allow for the inserted semicolons. However a single variable is limited to 32K characters in SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936183#M368012</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-18T14:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works because  to large string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936186#M368016</link>
      <description>&lt;P&gt;Related threads combined.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936186#M368016</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-18T14:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936190#M368018</link>
      <description>&lt;P&gt;If the result of CAT... functions is too long for the target variable then nothing is saved.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;1    data test;
2      A='stringA';
3      B='stringB';
4      C='stringC';
5      length full $20 ;
6      full=catx(';',a,b,c);
7    run;

WARNING: 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 23 characters, but the actual result might either be truncated to 20
         character(s) or be completely blank, depending on the calling environment. The following note indicates the left-most
         argument that caused truncation.
NOTE: Argument 4 to function CATX(';','stringA','stringB','stringC') at line 6 column 8 is invalid.
A=stringA B=stringB C=stringC full=  _ERROR_=1 _N_=1
NOTE: The data set WORK.TEST has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs       A          B          C       full

 1     stringA    stringB    stringC
&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;So define the variable long enough in the first place.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really want the value to be truncated so at least something is stored then wrap the function call in a SUBSTR() function call.&amp;nbsp; You can use VLENGTH() to get the defined length of the target variable.&lt;/P&gt;
&lt;PRE&gt;10   data test;
11     A='stringA';
12     B='stringB';
13     C='stringC';
14     length full $20 ;
15     full=substr(catx(';',a,b,c),1,vlength(full));
16   run;

NOTE: The data set WORK.TEST has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs       A          B          C               full

 1     stringA    stringB    stringC    stringA;stringB;stri
&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2024 14:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936190#M368018</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-18T14:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works because  to large string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936200#M368021</link>
      <description>I Have data inside my columns</description>
      <pubDate>Thu, 18 Jul 2024 15:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936200#M368021</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T15:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936203#M368023</link>
      <description>StringA B and C are in dataset , i have no values in var full with your method.&lt;BR /&gt;Thanks for yr help</description>
      <pubDate>Thu, 18 Jul 2024 15:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936203#M368023</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T15:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936204#M368024</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/448432"&gt;@Idi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;StringA B and C are in dataset , i have no values in var full with your method.&lt;BR /&gt;Thanks for yr help&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That makes no sense.&amp;nbsp;Just use the dataset you already have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume that A B and C exist in a dataset named HAVE and your goal is to make a new dataset named WANT that adds a new variable named FULL.&amp;nbsp; So make sure you define FULL long enough to store the longest possible value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length full $400 ;
  full=catx(';',a,b,c);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 15:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936204#M368024</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-18T15:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936207#M368025</link>
      <description>Thank you so much &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; , &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; , @Ballarddw&lt;BR /&gt;&lt;BR /&gt;I combined your answers&lt;BR /&gt;&lt;BR /&gt;the two proc codes helped me to understand the length of my data and i use length full $700 and and finally everything is displayed correctly&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc contents data=work.consoli;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=work.consoli (obs=95);&lt;BR /&gt;var A B C;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data work.amel;&lt;BR /&gt;set work.consoli;&lt;BR /&gt;length A $ 200;&lt;BR /&gt;length B $ 200;&lt;BR /&gt;length C $ 255;&lt;BR /&gt;length full $ 700;&lt;BR /&gt;full=catx(';',A,B,C); run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jul 2024 15:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936207#M368025</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T15:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936210#M368027</link>
      <description>&lt;P&gt;You cannot change the storage length of a variable once it has been set.&amp;nbsp; In your data step for the variables A B and C that is done when the SET statement checks what is in CONSOLI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either remove A B and C from the LENGTH statement(s).&amp;nbsp; Or move them to BEFORE the SET statement so they will actually have an impact.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 15:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936210#M368027</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-18T15:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concat with catx don't works , my string value to large</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936212#M368028</link>
      <description>Okay, thanks a lot, but its seems to be working well . Its solved the problem anyway.</description>
      <pubDate>Thu, 18 Jul 2024 17:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concat-with-catx-don-t-works-my-string-value-to-large/m-p/936212#M368028</guid>
      <dc:creator>Idi</dc:creator>
      <dc:date>2024-07-18T17:15:21Z</dc:date>
    </item>
  </channel>
</rss>

