<?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 not giving correct results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692784#M211116</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The catx function has been designed that way.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H3 id="p0prhxaj29aqfqn1hqtd1b8p2pi0" class="xisDoc-title"&gt;The Basics&lt;/H3&gt;
&lt;P class="xisDoc-paragraph"&gt;The CATX function first copies &lt;EM class="xisDoc-userSuppliedValue"&gt;item-1&lt;/EM&gt; to the result, omitting leading and trailing blanks. Next, for each subsequent argument &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt;, i=2, …, n, if &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt; contains at least one non-blank character, CATX appends &lt;EM class="xisDoc-userSuppliedValue"&gt;delimiter&lt;/EM&gt; and &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt; to the result, omitting leading and trailing blanks from &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt;. CATX does not insert the delimiter at the beginning or end of the result.&lt;EM&gt;&lt;STRONG&gt; Blank items do not produce delimiters at the beginning or end of the result, nor do blank items produce multiple consecutive delimiters&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 20 Oct 2020 08:30:51 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2020-10-20T08:30:51Z</dc:date>
    <item>
      <title>Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692776#M211109</link>
      <description>&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;new;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;x=&lt;/SPAN&gt;&lt;SPAN&gt;' '&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;z=&lt;/SPAN&gt;&lt;SPAN&gt;'abc'&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;new1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;new;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;zz=catx(&lt;/SPAN&gt;&lt;SPAN&gt;','&lt;/SPAN&gt;&lt;SPAN&gt;,x,z);&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;STRONG&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;I am trying to run this code but when I am opening the dataset new 1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;Variable ZZ has value abc .It is not having ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;why ZZ is not having a value &lt;STRONG&gt;,abc&lt;/STRONG&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="x_MsoNormal"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 07:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692776#M211109</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2020-10-20T07:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692781#M211113</link>
      <description>&lt;P&gt;Catx function removes leading and trailing spaces from concatenated strings.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 07:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692781#M211113</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-10-20T07:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692783#M211115</link>
      <description>hello&lt;BR /&gt;&lt;BR /&gt;I agree to you point that It removes leading and trailing spaces.But i have used the delimiter , in below statement&lt;BR /&gt;zz=catx(',',x,z);&lt;BR /&gt;&lt;BR /&gt;Why comma(,) is not coming in the output ?</description>
      <pubDate>Tue, 20 Oct 2020 08:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692783#M211115</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2020-10-20T08:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692784#M211116</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The catx function has been designed that way.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H3 id="p0prhxaj29aqfqn1hqtd1b8p2pi0" class="xisDoc-title"&gt;The Basics&lt;/H3&gt;
&lt;P class="xisDoc-paragraph"&gt;The CATX function first copies &lt;EM class="xisDoc-userSuppliedValue"&gt;item-1&lt;/EM&gt; to the result, omitting leading and trailing blanks. Next, for each subsequent argument &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt;, i=2, …, n, if &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt; contains at least one non-blank character, CATX appends &lt;EM class="xisDoc-userSuppliedValue"&gt;delimiter&lt;/EM&gt; and &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt; to the result, omitting leading and trailing blanks from &lt;EM class="xisDoc-userSuppliedValue"&gt;item-i&lt;/EM&gt;. CATX does not insert the delimiter at the beginning or end of the result.&lt;EM&gt;&lt;STRONG&gt; Blank items do not produce delimiters at the beginning or end of the result, nor do blank items produce multiple consecutive delimiters&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 20 Oct 2020 08:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692784#M211116</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-20T08:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692786#M211118</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I am running same code on SAS Host which I think is using SAS 9.2 there I am getting the , in the result&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this thing works on SAS 9.2 but not on SAS 9.4 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 08:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692786#M211118</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2020-10-20T08:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692788#M211119</link>
      <description>&lt;P&gt;You had posted a comma preceding the abc in your original post.&lt;/P&gt;
&lt;P&gt;Check again.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 08:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692788#M211119</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-10-20T08:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692793#M211121</link>
      <description>&lt;P&gt;Yes because I am using the function like this&lt;/P&gt;&lt;P&gt;zz=catx(',',x,z);&lt;/P&gt;&lt;P&gt;where x=, and Z='abc'&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 09:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692793#M211121</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2020-10-20T09:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692795#M211122</link>
      <description>&lt;P&gt;From what I take from the CATX section in&amp;nbsp;&lt;A href="https://www.lexjansen.com/scsug/2016/SCSUG_2016_Horstman_string_concatenation.pdf" target="_blank" rel="noopener"&gt;https://www.lexjansen.com/scsug/2016/SCSUG_2016_Horstman_string_concatenation.pdf&lt;/A&gt;, the behavior of CATX has been the same in 9.2. It might be that the variable used in your mainframe SAS code is not really empty, but has a non-displayable character.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 09:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692795#M211122</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-20T09:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692798#M211125</link>
      <description>&lt;P&gt;There is no difference in this regard in the SAS 9.2 documentation :&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002257076.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002257076.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check that it is indeed the same code that is run on the other host.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 09:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692798#M211125</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2020-10-20T09:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Catx function not giving correct results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692809#M211131</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127952"&gt;@shubham1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATX ignores arguments with missing values. It takes a list of variables and put a delimiter between &amp;lt;something&amp;gt; and &amp;lt;something&amp;gt;. So it never returns a string with a leading delimiter, a trailing delimiter or 2 or more consecutive delimiters.&amp;nbsp;If you want delimiters between all elements, missing or not, I don't think there is a simple function. But it can be done with an array, see the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
    a=' ';
    b = 'abc';
    c=' ';
    d=' ';
    e = 'efg';
    f=' ';
run;

* No delimiters between missing;
data _null;
    set new;
    zz=catx(',',a,b,c,d,e,f);
    put zz;
run;

/* Result:
abc,efg
*/

* Delimiters between all variables;
data _null_;
    set new;
    array elements[*] _character_;
    length zz $20.;
    zz = elements{1};
    do i = 2 to dim(elements);
        zz = trim(zz) || ',' || trim(elements{i});
    end;
    put zz=;
run;

/* Result:
,abc,,,efg,
*/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2020 10:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Catx-function-not-giving-correct-results/m-p/692809#M211131</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-10-20T10:39:10Z</dc:date>
    </item>
  </channel>
</rss>

