<?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 to use PROC FREQ to count characters under one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333897#M75305</link>
    <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  informat Symptoms $50.;
  input Symptoms &amp;amp;;
  cards;
C
C, A
W, A
C, W, A
W, R, V
;

data need;
  set have;
  _n_=1;
  do while (scan(Symptoms,_n_,',') ne '');
    symptom=scan(Symptoms,_n_,',');
    output;
    _n_+1;
  end;
run;

proc freq data=need;
  tables symptom;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 19:06:24 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-02-17T19:06:24Z</dc:date>
    <item>
      <title>How to use PROC FREQ to count characters under one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333885#M75300</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to get frequencies for a number of different symptoms experienced by patients in a data set. The problem is that they are all listed under the same variable: Symptoms and each column under it has a different string of letters depending on what the patient presented with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Symptoms&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;C&lt;/P&gt;&lt;P&gt;C, A&lt;/P&gt;&lt;P&gt;W, A&lt;/P&gt;&lt;P&gt;C, W, A&lt;/P&gt;&lt;P&gt;W, R, V&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been able to count the single letters but not all of the "C"'s "W"'s etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 18:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333885#M75300</guid>
      <dc:creator>edomachowske</dc:creator>
      <dc:date>2017-02-17T18:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use PROC FREQ to count characters under one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333897#M75305</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  informat Symptoms $50.;
  input Symptoms &amp;amp;;
  cards;
C
C, A
W, A
C, W, A
W, R, V
;

data need;
  set have;
  _n_=1;
  do while (scan(Symptoms,_n_,',') ne '');
    symptom=scan(Symptoms,_n_,',');
    output;
    _n_+1;
  end;
run;

proc freq data=need;
  tables symptom;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 19:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333897#M75305</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-17T19:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use PROC FREQ to count characters under one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333898#M75306</link>
      <description>&lt;P&gt;You need to loop over each individual symptom in symptons.&amp;nbsp; Output each of the individuals, and then run proc freq:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input symptoms $8.;
datalines;
C
C, A
W, A
C, W, A
W, R, V
run;

data vhave/ view=vhave;
  set have;
  length symptom $1.;
  do I=1 to countw(symptoms,',');
    symptom= left(scan(symptoms,I,','));
	output;
  end;
run;
proc freq data=vhave;
  tables symptom;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2017 19:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/333898#M75306</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-17T19:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use PROC FREQ to count characters under one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/334029#M75374</link>
      <description>&lt;P&gt;Better post the output you need too .&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 04:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-PROC-FREQ-to-count-characters-under-one-variable/m-p/334029#M75374</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-02-18T04:39:37Z</dc:date>
    </item>
  </channel>
</rss>

