<?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: Optimize CATX Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693469#M211447</link>
    <description>&lt;P&gt;Pull the first condition and its part of the CATX's out into a separate DO/END block:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
set test1;
if not missing(aval)
then do;
  result = put(round(aval,test_dec),best.);
  if lbnrind ne "" and lbclsig ne ""
  then result = catx(' ',
    result,
    '('!!strip(substr(lbnrind,1,1))!!')',
    '('!!strip(lbclsig)!!')'
  );
  if lbclsig ne "" and lbnrind = ""
  then result = catx(' ', result, '('!!strip(lbclsig)!!')');
  if lbclsig = "" and lbnrind ne ""
  then result = catx(' ',result,'('!!strip(substr(lbnrind,1,1))!!')');
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also replaced the CMISS functions with direct comparisons, as those variables can be assumed to be character anyway; direct comparisons are faster than function calls.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Oct 2020 12:04:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-10-22T12:04:51Z</dc:date>
    <item>
      <title>Optimize CATX Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693466#M211445</link>
      <description>&lt;P&gt;Dear SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me how to optimize or to paraphrase this code into more elegant. I make some code using CATX function. The goal is i want to have three different option in result variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waldorf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test1;&lt;BR /&gt;SET table_005_test_dec;&lt;BR /&gt;KEEP aval lbnrind lbclsig test_dec;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA test2;&lt;BR /&gt;SET test1;&lt;BR /&gt;IF NOT MISSING(aval) AND CMISS(lbnrind,lbclsig) = 0 THEN DO;&lt;BR /&gt;result = CATX(' ', PUT(ROUND(aval, test_dec), best.), '('!!STRIP(SUBSTR(lbnrind, 1, 1))!!')', '('!!STRIP(lbclsig)!!')');&lt;BR /&gt;END;&lt;BR /&gt;IF NOT MISSING(aval) AND CMISS(lbclsig) = 0 AND CMISS(lbnrind) = 1 THEN DO;&lt;BR /&gt;result = CATX(' ', PUT(ROUND(aval, test_dec), best.), '('!!STRIP(lbclsig)!!')');&lt;BR /&gt;END;&lt;BR /&gt;IF NOT MISSING(aval) AND CMISS(lbclsig) = 1 AND CMISS(lbnrind) = 0 THEN DO;&lt;BR /&gt;result = CATX(' ', PUT(ROUND(aval, test_dec), best.), '('!!STRIP(SUBSTR(lbnrind, 1, 1))!!')');&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 11:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693466#M211445</guid>
      <dc:creator>Longbottom_88</dc:creator>
      <dc:date>2020-10-22T11:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize CATX Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693469#M211447</link>
      <description>&lt;P&gt;Pull the first condition and its part of the CATX's out into a separate DO/END block:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
set test1;
if not missing(aval)
then do;
  result = put(round(aval,test_dec),best.);
  if lbnrind ne "" and lbclsig ne ""
  then result = catx(' ',
    result,
    '('!!strip(substr(lbnrind,1,1))!!')',
    '('!!strip(lbclsig)!!')'
  );
  if lbclsig ne "" and lbnrind = ""
  then result = catx(' ', result, '('!!strip(lbclsig)!!')');
  if lbclsig = "" and lbnrind ne ""
  then result = catx(' ',result,'('!!strip(substr(lbnrind,1,1))!!')');
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also replaced the CMISS functions with direct comparisons, as those variables can be assumed to be character anyway; direct comparisons are faster than function calls.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 12:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693469#M211447</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-22T12:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize CATX Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693530#M211486</link>
      <description>&lt;P&gt;If you are using the !! in this to concatenate you might consider nesting a cats call&lt;/P&gt;
&lt;P&gt;'('!!STRIP(SUBSTR(lbnrind, 1, 1))!!')'&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cats ( '(',SUBSTR(lbnrind, 1, 1),')' )&lt;/P&gt;
&lt;P&gt;may not "optimize" but is less typing and a bit easier to follow. Plus with CATS you shouldn't need the STRIP function call.&amp;nbsp; You can nest the various CAT functions inside each other just like using the SUBSTR or other functions.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2020 15:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/693530#M211486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-22T15:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize CATX Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/694172#M211690</link>
      <description>Hi Kurt, Thanks for the answer. Cheers</description>
      <pubDate>Mon, 26 Oct 2020 07:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/694172#M211690</guid>
      <dc:creator>Longbottom_88</dc:creator>
      <dc:date>2020-10-26T07:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize CATX Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/694173#M211691</link>
      <description>Hi Ballardw, thanks for the answer. Cheers</description>
      <pubDate>Mon, 26 Oct 2020 07:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimize-CATX-Function/m-p/694173#M211691</guid>
      <dc:creator>Longbottom_88</dc:creator>
      <dc:date>2020-10-26T07:50:05Z</dc:date>
    </item>
  </channel>
</rss>

