<?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 Frequency Count of a String in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280603#M56724</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a set of observations where: when a rule is activated, it simply populated a field as a string with a semi-colon dilineator. The rules can be out of order, some are long, some are short, etc. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to cross tabulate on a string of texts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Observation Pass Rule_String&lt;BR /&gt;1 1 Rule A;Rule C;Rule D&lt;BR /&gt;2 0 Rule C;Rule B&lt;BR /&gt;3 1 Rule A;Rule B&lt;BR /&gt;&lt;BR /&gt;Want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Rule Count Pass&lt;BR /&gt;A 2 2&lt;BR /&gt;B 2 1&lt;BR /&gt;C 2 1&lt;BR /&gt;D 1 1&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2016 22:13:36 GMT</pubDate>
    <dc:creator>JS</dc:creator>
    <dc:date>2016-06-27T22:13:36Z</dc:date>
    <item>
      <title>Frequency Count of a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280603#M56724</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a set of observations where: when a rule is activated, it simply populated a field as a string with a semi-colon dilineator. The rules can be out of order, some are long, some are short, etc. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to cross tabulate on a string of texts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Observation Pass Rule_String&lt;BR /&gt;1 1 Rule A;Rule C;Rule D&lt;BR /&gt;2 0 Rule C;Rule B&lt;BR /&gt;3 1 Rule A;Rule B&lt;BR /&gt;&lt;BR /&gt;Want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Rule Count Pass&lt;BR /&gt;A 2 2&lt;BR /&gt;B 2 1&lt;BR /&gt;C 2 1&lt;BR /&gt;D 1 1&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 22:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280603#M56724</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-06-27T22:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency Count of a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280614#M56730</link>
      <description>&lt;P&gt;You will need to split them out first, but that's not terribly difficult. &amp;nbsp;Here's one approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data split;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if rule_string &amp;gt; &amp;nbsp;' ' then do i=1 to countw(rule_string, ';');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;rule = scan(rule_string, i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc means data=split n sum;&lt;/P&gt;
&lt;P&gt;class rule;&lt;/P&gt;
&lt;P&gt;var pass;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 00:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280614#M56730</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-28T00:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Frequency Count of a String</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280616#M56732</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Observation Pass Rule_String&amp;amp;$20.;
newstring=strip(tranwrd(Rule_String,'Rule',''));
datalines4;
1 1 Rule A;Rule C;Rule D
2 0 Rule C;Rule B
3 1 Rule A;Rule B
;;;;

/*to get the individual records of data*/
data want(where=(string ne ''));
set have;
do i = 1 to countw(newstring);
string=strip(scan(newstring,i,';'));
output;
end;
run;

/*to count the string*/
proc freq data=want noprint;
table string/out=count1;
run;

/*to count the pass*/
proc freq data=want noprint;
where pass ne 0;
table string*pass/out=count2(rename=(count=pass2));
run;

/*final dataset*/
data all(rename=(pass2=pass));
merge count1 count2;
by string;
drop percent pass;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 01:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Frequency-Count-of-a-String/m-p/280616#M56732</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-06-28T01:06:29Z</dc:date>
    </item>
  </channel>
</rss>

