<?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 Proc freq count of multiple variables treated as 1 variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353112#M82404</link>
    <description>&lt;P&gt;I have a dataset with 4 variables that basically is the same variable that house intervention codes. Is there a proc freq code that I can use to treat the 4 variables the same variable to get an overall frequency distribution of all 4 variables? Here is the sample dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SAMPINT;
  infile datalines dsd truncover;
  input ID:BEST. Intervention1:$3. Intervention2:$3. Intervention3:$3. Intervention4:$3.;
datalines4;
1,BB8,ABC,ABC,
2,BB8,ABC,CCC,
3,,BB8,,
4,,,BB8,
5,,,,BB8
6,,CCC,,
7,ABC,,,
8,,BB8,,ABC
9,,BB8,,
10,,,,
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Essentially, I would like the output to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Intervention&lt;/TD&gt;&lt;TD&gt;Frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BB8&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCC&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;Thanks alot for your help!&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2017 07:33:34 GMT</pubDate>
    <dc:creator>byeh2017</dc:creator>
    <dc:date>2017-04-25T07:33:34Z</dc:date>
    <item>
      <title>Proc freq count of multiple variables treated as 1 variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353112#M82404</link>
      <description>&lt;P&gt;I have a dataset with 4 variables that basically is the same variable that house intervention codes. Is there a proc freq code that I can use to treat the 4 variables the same variable to get an overall frequency distribution of all 4 variables? Here is the sample dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SAMPINT;
  infile datalines dsd truncover;
  input ID:BEST. Intervention1:$3. Intervention2:$3. Intervention3:$3. Intervention4:$3.;
datalines4;
1,BB8,ABC,ABC,
2,BB8,ABC,CCC,
3,,BB8,,
4,,,BB8,
5,,,,BB8
6,,CCC,,
7,ABC,,,
8,,BB8,,ABC
9,,BB8,,
10,,,,
;;;;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Essentially, I would like the output to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Intervention&lt;/TD&gt;&lt;TD&gt;Frequency&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;BB8&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CCC&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;Thanks alot for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 07:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353112#M82404</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-25T07:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq count of multiple variables treated as 1 variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353114#M82405</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SAMPINT;
  infile datalines dsd truncover;
  input ID:BEST. Intervention1:$3. Intervention2:$3. Intervention3:$3. Intervention4:$3.;
datalines4;
1,BB8,ABC,ABC,
2,BB8,ABC,CCC,
3,,BB8,,
4,,,BB8,
5,,,,BB8
6,,CCC,,
7,ABC,,,
8,,BB8,,ABC
9,,BB8,,
10,,,,
;;;;

proc transpose data=SAMPINT
   out=long_SAMPINT(rename=(Col1=Intervention) drop = _NAME_);                    
   by ID;               
   var Intervention1-Intervention4;
run;

proc freq data = long_SAMPINT;
	tables Intervention / nocum nopercent;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 07:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353114#M82405</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-25T07:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq count of multiple variables treated as 1 variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353119#M82408</link>
      <description>&lt;P&gt;If you are fond of writing code, using a hash object can replace both procs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set work.sampint end=done;

   length Intervention $ 3 Frequency 8;

   array inter Intervention1-Intervention4;

   if _n_ = 1 then do;
      declare hash h(/*ordered: 'YES'*/);
      h.defineKey('Intervention');
      h.defineData('Intervention', 'Frequency');
      h.defineDone();
   end;

   do i = 1 to dim(inter);
      if not missing(inter[i]) then do;
         Intervention = inter[i];

         if h.find() ^= 0 then do;            
            Frequency = 1;
            h.add();
         end;
         else do;
            Frequency = Frequency + 1;
            h.replace();
         end;
      end;
   end;

   if done then do;
      h.output(dataset: 'work.want');
   end;
run;

proc print data=work.want;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 08:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353119#M82408</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-04-25T08:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc freq count of multiple variables treated as 1 variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353188#M82426</link>
      <description>&lt;P&gt;Thanks. Is there a way to limit the final output to the top 5 observations in descending order?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 13:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-freq-count-of-multiple-variables-treated-as-1-variable/m-p/353188#M82426</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-25T13:43:10Z</dc:date>
    </item>
  </channel>
</rss>

