<?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 Scan does not work inside of CATX in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857691#M338898</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create value based on characters in variable names after certain string. The following is the code that generates blank when combined catx with scan:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data master1_color;
  length color_new $50;
  set master1;
   array r ABC_WHITE ABC_BLACK ABC_YELLOW ABC_RED ACS_OTHER;
    do _i = 1 to dim(r);
      if r[_i] = '1' then color_new = catx('/',color_new,scan(vname(r(_i))-1,'_'));&lt;BR /&gt;    end;&lt;BR /&gt;  drop i;&lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm hoping to generate values such as:&lt;/P&gt;&lt;P&gt;Color_new:&lt;/P&gt;&lt;P&gt;WHITE/BLACK&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;BLACK/RED&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the catx outputs blanks instead of concatenated strings. It will work if I remove scan in catx.&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2023 07:19:31 GMT</pubDate>
    <dc:creator>lydiawawa</dc:creator>
    <dc:date>2023-02-08T07:19:31Z</dc:date>
    <item>
      <title>Scan does not work inside of CATX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857691#M338898</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create value based on characters in variable names after certain string. The following is the code that generates blank when combined catx with scan:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data master1_color;
  length color_new $50;
  set master1;
   array r ABC_WHITE ABC_BLACK ABC_YELLOW ABC_RED ACS_OTHER;
    do _i = 1 to dim(r);
      if r[_i] = '1' then color_new = catx('/',color_new,scan(vname(r(_i))-1,'_'));&lt;BR /&gt;    end;&lt;BR /&gt;  drop i;&lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm hoping to generate values such as:&lt;/P&gt;&lt;P&gt;Color_new:&lt;/P&gt;&lt;P&gt;WHITE/BLACK&lt;/P&gt;&lt;P&gt;BLACK&lt;/P&gt;&lt;P&gt;BLACK/RED&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the catx outputs blanks instead of concatenated strings. It will work if I remove scan in catx.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 07:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857691#M338898</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2023-02-08T07:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Scan does not work inside of CATX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857697#M338899</link>
      <description>&lt;P&gt;Have a closer look at the parameters of scan: i think a comma is missing right after calling vname.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 08:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857697#M338899</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-02-08T08:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Scan does not work inside of CATX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857704#M338902</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;yep a comma is missing and you could light your code up&lt;/P&gt;
&lt;PRE&gt;DATA master1;
input ABC_WHITE $ ABC_BLACK $ ABC_YELLOW $ ABC_RED $ ACS_OTHER $;
datalines;
0 0 0 0 0
1 0 0 0 0
0 1 0 0 1
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1 1 1 1 1
;
run;

DATA master1_color;
   LENGTH color_new $50;
   SET master1;
   ARRAY r _CHARACTER_;
   do over r;
      if r = '1' then color_new = catx('/',color_new,scan(vname(r),-1,'_'));
   end;
RUN;    &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 09:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-does-not-work-inside-of-CATX/m-p/857704#M338902</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-02-08T09:51:17Z</dc:date>
    </item>
  </channel>
</rss>

