<?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: count the number of character occurrences throughout the data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495997#M72396</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need (keep=infection) / view=need;
  set have  ;
  array inf {*} infection_: ;
  length infection $12;
  do I=1 to dim(inf) while (inf{I}^=' ');
    infection=inf{I};
    output;
  end;
run;

proc freq data=need;
  tables infection;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program assumes that if a row has fewer than 3 infections, the non-blank values are the leftmost.&lt;/P&gt;</description>
    <pubDate>Sun, 16 Sep 2018 03:07:53 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-09-16T03:07:53Z</dc:date>
    <item>
      <title>count the number of character occurrences throughout the data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495746#M72378</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset filled with character variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;patient&lt;/TD&gt;&lt;TD&gt;infection_1&lt;/TD&gt;&lt;TD&gt;infection_2&lt;/TD&gt;&lt;TD&gt;infection_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;abc&lt;/TD&gt;&lt;TD&gt;virus&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xyz&lt;/TD&gt;&lt;TD&gt;fungus&lt;/TD&gt;&lt;TD&gt;virus&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;lmn&lt;/TD&gt;&lt;TD&gt;bacteria&lt;/TD&gt;&lt;TD&gt;fungus&lt;/TD&gt;&lt;TD&gt;virus&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to produce one frequency table to find all occurrences&amp;nbsp;in the variable:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;any infection&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;virus&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;fungus&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;bacteria&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a shorter way in SAS to do this? Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 15:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495746#M72378</guid>
      <dc:creator>jcapua2</dc:creator>
      <dc:date>2018-09-14T15:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of character occurrences throughout the data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495748#M72379</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (patient	infection_1	infection_2	infection_3) (:$10.);
cards;
abc	virus	. . 	 
xyz	fungus	virus	. 
lmn	bacteria	fungus	virus
;

proc transpose data=have out=_have(keep=col1 where=(col1 ne ' ' ));
by patient notsorted;
var infection:;
run;

proc freq data=_have noprint;
tables col1/out=want(keep=col1 count);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 16:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495748#M72379</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-14T16:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: count the number of character occurrences throughout the data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495997#M72396</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need (keep=infection) / view=need;
  set have  ;
  array inf {*} infection_: ;
  length infection $12;
  do I=1 to dim(inf) while (inf{I}^=' ');
    infection=inf{I};
    output;
  end;
run;

proc freq data=need;
  tables infection;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program assumes that if a row has fewer than 3 infections, the non-blank values are the leftmost.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 03:07:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/count-the-number-of-character-occurrences-throughout-the-data/m-p/495997#M72396</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-09-16T03:07:53Z</dc:date>
    </item>
  </channel>
</rss>

