<?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: How do I count the number of times a character appears in a string? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703539#M26046</link>
    <description>&lt;P&gt;Easy enough to test a function. Find the required parameters from the documentation of function and then use it. A vast majority of the functions in the SAS documentation have at least one example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From Countc:&lt;/P&gt;
&lt;PRE&gt;data test;
   string  = 'Baboons Eat Bananas     ';
   a       = countc(string, 'a');
   b       = countc(string, 'b');
   b_i     = countc(string, 'b', 'i');
   abc_i   = countc(string, 'abc', 'i');
      /* Scan string for characters that are not "a", "b", */
      /* and "c", ignore case, (and include blanks).       */
   abc_iv  = countc(string, 'abc', 'iv');
      /* Scan string for characters that are not "a", "b", */
      /* and "c", ignore case, and trim trailing blanks.   */
   abc_ivt = countc(string, 'abc', 'ivt');
run;
&lt;/PRE&gt;
&lt;P&gt;Key part are the source, the variable String above, and the character list to search for, the second parameter. The 3rd optional parameter has to do with ignoring letter case, adding or excluding certain types of characters that are hard to type and keep in code such as Tab or control characters (ancient stuff from teletype but include things like the "ring bell", vertical space without end of line, and stuff)&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2020 02:44:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-12-04T02:44:03Z</dc:date>
    <item>
      <title>How do I count the number of times a character appears in a string?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703530#M26040</link>
      <description>&lt;P&gt;Count the number of times the string ‘ ? ‘ occurs in variable line. Choose any method that works reliably. Regardless of method, assume that a line won’t consist entirely of ‘ ? ‘’s.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 01:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703530#M26040</guid>
      <dc:creator>klj4y</dc:creator>
      <dc:date>2020-12-04T01:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count the number of times a character appears in a string?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703534#M26042</link>
      <description>&lt;P&gt;So what strategies, in words, do you think might work?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 01:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703534#M26042</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-12-04T01:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count the number of times a character appears in a string?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703535#M26043</link>
      <description>&lt;P&gt;I would think the countc function. We were not provided data to test it on so i'm not sure how it would work.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 02:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703535#M26043</guid>
      <dc:creator>klj4y</dc:creator>
      <dc:date>2020-12-04T02:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count the number of times a character appears in a string?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703539#M26046</link>
      <description>&lt;P&gt;Easy enough to test a function. Find the required parameters from the documentation of function and then use it. A vast majority of the functions in the SAS documentation have at least one example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From Countc:&lt;/P&gt;
&lt;PRE&gt;data test;
   string  = 'Baboons Eat Bananas     ';
   a       = countc(string, 'a');
   b       = countc(string, 'b');
   b_i     = countc(string, 'b', 'i');
   abc_i   = countc(string, 'abc', 'i');
      /* Scan string for characters that are not "a", "b", */
      /* and "c", ignore case, (and include blanks).       */
   abc_iv  = countc(string, 'abc', 'iv');
      /* Scan string for characters that are not "a", "b", */
      /* and "c", ignore case, and trim trailing blanks.   */
   abc_ivt = countc(string, 'abc', 'ivt');
run;
&lt;/PRE&gt;
&lt;P&gt;Key part are the source, the variable String above, and the character list to search for, the second parameter. The 3rd optional parameter has to do with ignoring letter case, adding or excluding certain types of characters that are hard to type and keep in code such as Tab or control characters (ancient stuff from teletype but include things like the "ring bell", vertical space without end of line, and stuff)&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 02:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703539#M26046</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-04T02:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I count the number of times a character appears in a string?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703546#M26047</link>
      <description>Classmates or hiring exam? &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-count-upcase-letter-from-a-string-in-Base-SAS/m-p/703460" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-count-upcase-letter-from-a-string-in-Base-SAS/m-p/703460&lt;/A&gt;</description>
      <pubDate>Fri, 04 Dec 2020 04:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-count-the-number-of-times-a-character-appears-in-a/m-p/703546#M26047</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-12-04T04:16:56Z</dc:date>
    </item>
  </channel>
</rss>

