<?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: Searching and Counting for Multiple Substrings Across an Array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621563#M182720</link>
    <description>&lt;P&gt;No apology necessary! I hadn't even thought of that possibility until&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;brought it up. Appreciate the modification suggestion.&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2020 21:52:50 GMT</pubDate>
    <dc:creator>A_SAS_Man</dc:creator>
    <dc:date>2020-01-31T21:52:50Z</dc:date>
    <item>
      <title>Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621555#M182713</link>
      <description>&lt;P&gt;I am attempting to count the instances that an array of columns has of specific letters (C,D,K). For example I have the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;&lt;BR /&gt;input dx1 $ dx2 $ dx3 $;&lt;BR /&gt;datalines;&lt;BR /&gt;d12 l34 r23&lt;BR /&gt;t67 u12 p90&lt;BR /&gt;k13 c56 _&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;I want to generate the following off of it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input dx1 $ dx2 $ dx3 $ count;
datalines;
d12 l34 r23 1
t67 u12 p90 0
k13 c56 _   2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As a corollary off of this I am also interested in how to take the substring of each element of the array to get the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
input dx1 $ dx2 $ dx3 $ adx1 $ adx2 $ adx3 $;
datalines;
d12 l34 r23 d l r
t67 u12 p90 t u p
k13 c56 _   k c 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621555#M182713</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2020-01-31T21:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621557#M182715</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input dx1 $ dx2 $ dx3 $;
datalines;
d12 l34 r23
t67 u12 p90
k13 c56 _
;
run;

data want;
 set have;
 array d dx1-dx3;
 array e $ adx1  adx2  adx3 ;
 count=countc(catx(' ',of d(*)),'cdk');
 do over d;
  e=char(d,1);
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621557#M182715</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-31T21:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621559#M182717</link>
      <description>&lt;P&gt;What if the same letter repeats in different variables? Count as 1 only or number of occurrences?&lt;/P&gt;
&lt;P&gt;Is case a consideration? I.E. you have values of K12 and k12. Only count the lower or upper case or count both?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;K12&amp;nbsp;&amp;nbsp; C56 K43&amp;nbsp;&amp;nbsp; is that a 2 or 3 result?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621559#M182717</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-31T21:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621561#M182718</link>
      <description>&lt;P&gt;I would like to count number of a occurrences (so 3 in your example). If I could make it count both upper and lower cases that would be ideal, I believe the solution above will only count ones that match case.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621561#M182718</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2020-01-31T21:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621562#M182719</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234586"&gt;@A_SAS_Man&lt;/a&gt;&amp;nbsp; My apologies, you could add a modifier in the COUNTC function to perform a case insensitive find/count.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the change would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; count=countc(catx(' ',of d(*)),'cdk','i');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621562#M182719</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-31T21:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621563#M182720</link>
      <description>&lt;P&gt;No apology necessary! I hadn't even thought of that possibility until&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;brought it up. Appreciate the modification suggestion.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 21:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621563#M182720</guid>
      <dc:creator>A_SAS_Man</dc:creator>
      <dc:date>2020-01-31T21:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and Counting for Multiple Substrings Across an Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621565#M182722</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/234586"&gt;@A_SAS_Man&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;No apology necessary! I hadn't even thought of that possibility until&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;brought it up. Appreciate the modification suggestion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Now for the fun values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to have a variable with a value like: KC1?&lt;/P&gt;
&lt;P&gt;You may want to check your data looking for unique values before answering. You might have some actual values that are not supposed to be in the data (human entry errors for example).&lt;/P&gt;
&lt;P&gt;Or if you have valid values like KC1 is that a 1 count or a 2 count?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 22:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Searching-and-Counting-for-Multiple-Substrings-Across-an-Array/m-p/621565#M182722</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-31T22:10:52Z</dc:date>
    </item>
  </channel>
</rss>

