<?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: Scan across array and count into new column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scan-across-array-and-count-into-new-column/m-p/824744#M325726</link>
    <description>&lt;P&gt;That is exactly what the COUNT() function does.&amp;nbsp; Just use the CATS() function to convert your set of variables into a single string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  input state $ county $ (storeid_1-storeid_5) (:$15.) ;
  nchain = count(cats(of storeid_1-storeid_5),'Chain');
  nmp  = count(cats(of storeid_1-storeid_5),'Mom&amp;amp;Pop');
cards;
01 001 123,Chain 124,Chain 125,Mom&amp;amp;Pop 126,Mom&amp;amp;Pop 127,Chain
01 002 111,Chain 112,Chain 113,Chain 114,Mom&amp;amp;Pop 115,Chain
01 003 101,Chain 102,Chain 103,Chain 104,Chain 105,Chain
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Jul 2022 18:41:05 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-07-21T18:41:05Z</dc:date>
    <item>
      <title>Scan across array and count into new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-across-array-and-count-into-new-column/m-p/824743#M325725</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm attempting to find a specific string across several columns and count the number of times this string appears and then place that count as a new variable. Would this be a use of an array and scan function? Or would this perhaps be something like a count function? Any guidance would be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data NewData;

input state $ county $ storeid_1 $ storeid_2 $ storeid_3 $ storeid_4 $ storeid_5 $;
cards;
01 001 123,Chain 124,Chain 125,Mom&amp;amp;Pop 126,Mom&amp;amp;Pop 127,Chain
01 002 111,Chain 112,Chain 113,Chain 114,Mom&amp;amp;Pop 115,Chain
01 003 101,Chain 102,Chain 103,Chain 104,Chain 105,Chain
;
run;
&lt;/PRE&gt;
&lt;PRE&gt;Data want;

input state $ county $ storeid_1 $ storeid_2 $ storeid_3 $ storeid_4 $ storeid_5 $ num_store_chain num_store_mp;
cards;
01 001 123,Chain 124,Chain 125,Mom&amp;amp;Pop 126,Mom&amp;amp;Pop 127,Chain 3 2
01 002 111,Chain 112,Chain 113,Chain 114,Mom&amp;amp;Pop 115,Chain 4 1
01 003 101,Chain 102,Chain 103,Chain 104,Chain 105,Chain 5 0
;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2022 18:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-across-array-and-count-into-new-column/m-p/824743#M325725</guid>
      <dc:creator>A_Swoosh</dc:creator>
      <dc:date>2022-07-21T18:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scan across array and count into new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-across-array-and-count-into-new-column/m-p/824744#M325726</link>
      <description>&lt;P&gt;That is exactly what the COUNT() function does.&amp;nbsp; Just use the CATS() function to convert your set of variables into a single string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  input state $ county $ (storeid_1-storeid_5) (:$15.) ;
  nchain = count(cats(of storeid_1-storeid_5),'Chain');
  nmp  = count(cats(of storeid_1-storeid_5),'Mom&amp;amp;Pop');
cards;
01 001 123,Chain 124,Chain 125,Mom&amp;amp;Pop 126,Mom&amp;amp;Pop 127,Chain
01 002 111,Chain 112,Chain 113,Chain 114,Mom&amp;amp;Pop 115,Chain
01 003 101,Chain 102,Chain 103,Chain 104,Chain 105,Chain
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2022 18:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-across-array-and-count-into-new-column/m-p/824744#M325726</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-21T18:41:05Z</dc:date>
    </item>
  </channel>
</rss>

