<?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: Find most frequent response across multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269862#M269444</link>
    <description>&lt;P&gt;Thanks all for the various approaches. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FreelanceReinhard's code is ready to go, for the most frequent response. Thanks a lot (so that I don't need to write additional code or revise code).&lt;BR /&gt;stat_sas's code works when I want the max value and its count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've filed away all for future reference. Thanks again for your help.&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2016 19:40:39 GMT</pubDate>
    <dc:creator>Solph</dc:creator>
    <dc:date>2016-05-11T19:40:39Z</dc:date>
    <item>
      <title>Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269774#M269434</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I find the most frequent response for each person across&amp;nbsp;a list of variables? Ideally I'd like to know the frequency count of the "most frequent &amp;nbsp;response".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's a tie,&amp;nbsp;either would be fine&amp;nbsp;(although it would be nice if there is a way to choose without long SAS programming code)&lt;/P&gt;
&lt;P&gt;Also my data are string variables (with values 01-10) data but if code-wise it's easier to do numerical, I can make them numerical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have; &lt;BR /&gt; input id 1 x1 $ 4-5 x2 $ 7-8 x3 $ 10-11 x4 $ 13-14 x5 $ 16-17;&lt;BR /&gt;cards;&lt;BR /&gt;1 07 04 07 07 07&lt;BR /&gt;2 04 05 04 04 05&lt;BR /&gt;3 02 02 &amp;nbsp; &amp;nbsp;03&lt;BR /&gt;4 01 01 02 02&lt;BR /&gt;5 01&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want:&lt;BR /&gt;ID X1 X2 X3 X4 X5 MostFreq Count&lt;BR /&gt;1 07 04 07 07 07 &amp;nbsp; 07 3&lt;BR /&gt;2 04 05 04 04 05 &amp;nbsp; 04 3 &lt;BR /&gt;3 02 02 03 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02 2 &lt;BR /&gt;4 01 01 02 02 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01 &amp;nbsp;2 (or 02 &amp;nbsp;2)&lt;BR /&gt;5 05 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05 &amp;nbsp;1&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269774#M269434</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2016-05-11T16:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269778#M269435</link>
      <description>&lt;P&gt;Sorry, posted it before I finished composing. My question was if there is some efficient way to do it?&amp;nbsp;I don't know if SAS has some ready to use code to do multiple response (like SPSS has) and write out the values into the datatset, or like the max/min functions (xx=max(of x1-x5) that can easily identify the max/min values out of a list of variables. The code I can come up with to get the most frequent response is a really really long one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269778#M269435</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2016-05-11T16:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269780#M269436</link>
      <description>&lt;P&gt;The fastest way is to transpose your data, from wide to long, &amp;nbsp;use a proc freq and then re-transpose to desired structure. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you need help coding that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc transpose can flip your data each way.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269780#M269436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-11T16:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269787#M269437</link>
      <description>&lt;P&gt;I would recommend an approach that gives you a little more flexibility ... get 5 counts instead of 1 maximum count.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array x {5};&lt;/P&gt;
&lt;P&gt;array count {5};&lt;/P&gt;
&lt;P&gt;do _i_=1 to 5;&lt;/P&gt;
&lt;P&gt;count{_i_}=0;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if x{_i_} = x{_n_} then count{_i_} + 1;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end of this, COUNT1 will be the number of times that the X1 answer appears, COUNT2 the number of times that the X2 answer appears, etc.&amp;nbsp; You can easily add to this DATA step with statements such as these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;maxcount = max(of count1-count5);&lt;/P&gt;
&lt;P&gt;maxvar = whichn(maxcount, of count1-count5);&lt;/P&gt;
&lt;P&gt;varname = vname(x{maxvar});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This way you can easily detect ties for the maximum count, detect answers that only appear once, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269787#M269437</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-11T16:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269789#M269438</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19901"&gt;@Solph﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
length MostFreq $2;
array x x:;
array _t[10] _temporary_;
call missing(of _t[*]);
do _n_=1 to dim(x);
  if x[_n_] ne ' ' then _t[input(x[_n_],2.)]+1;
end;
Count=max(of _t[*]);
MostFreq=put(whichn(Count, of _t[*]),z2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is for character variables x1, x2, ... For numeric variables it could be simplified.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269789#M269438</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T16:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269797#M269439</link>
      <description>&lt;P&gt;data want(drop=i);&lt;BR /&gt;set have;&lt;BR /&gt;array x{*} x:;&lt;BR /&gt;do i=1 to dim(x);&lt;BR /&gt;MostFreq=max(of x(*));&lt;BR /&gt;Count=countc(cats(of x(*)),MostFreq,'i');&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269797#M269439</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-05-11T16:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find the most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269800#M269440</link>
      <description>&lt;P&gt;You meant to have the vertical data? I think it worked perfectly. Here is what I did after transposing. Let me know if there is a better way.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sort; by id;&lt;BR /&gt;proc freq; by id; table x /out=xx (drop=percent); run;&lt;BR /&gt;proc print noobs; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It outputted ID, x (01-10) and count for each ID and each X value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE class="table" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="header" scope="colgroup"&gt;id&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;COUNT&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;07&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;05&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269800#M269440</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2016-05-11T16:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269803#M269441</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42042"&gt;@stat_sas&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;MostFreq=max(of x(*));&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42042"&gt;@stat_sas&lt;/a&gt;: Why should the &lt;EM&gt;largest&lt;/EM&gt; value coincide with the &lt;EM&gt;most frequent&lt;/EM&gt; value?&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 16:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269803#M269441</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-11T16:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269807#M269442</link>
      <description>&lt;P&gt;I thought about using array&amp;nbsp;to count but got stuck for the rest.&amp;nbsp;I liked the code because it indeed gives more flexibliity for further manipulation, but&lt;/P&gt;
&lt;P&gt;-&amp;nbsp;I need to assign a new variable associating varname values (e.g. x1 in the first row) to varaible name x1's value of 07, so that I can create a variable with a value of 07? How do I do it&lt;/P&gt;
&lt;P&gt;- How come count for ID=5 didn't look right? Is it because it's counting missing? (Looks like it, for ID 3 and 4 too).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;TABLE class="table" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;COL class="data" /&gt; &lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="header" scope="colgroup"&gt;id&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x1&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x2&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x3&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x4&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;x5&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;count1&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;count2&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;count3&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;count4&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;count5&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;_i_&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;maxcount&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;maxvar&lt;/TH&gt;
&lt;TH class="header" scope="colgroup"&gt;varname&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;07&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;07&lt;/TD&gt;
&lt;TD class="b data"&gt;07&lt;/TD&gt;
&lt;TD class="b data"&gt;07&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;6&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;05&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;04&lt;/TD&gt;
&lt;TD class="b data"&gt;05&lt;/TD&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;6&lt;/TD&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;3&lt;/TD&gt;
&lt;TD class="b data"&gt;02&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;02&lt;/TD&gt;
&lt;TD class="b data"&gt;03&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;6&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;01&lt;/TD&gt;
&lt;TD class="b data"&gt;01&lt;/TD&gt;
&lt;TD class="b data"&gt;02&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;02&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;6&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="b data"&gt;5&lt;/TD&gt;
&lt;TD class="b data"&gt;01&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="b data"&gt;1&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;6&lt;/TD&gt;
&lt;TD class="b data"&gt;4&lt;/TD&gt;
&lt;TD class="b data"&gt;2&lt;/TD&gt;
&lt;TD class="b data"&gt;x2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 17:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269807#M269442</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2016-05-11T17:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269808#M269443</link>
      <description>&lt;P&gt;A few variations, then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; you don't want to count missing values, change one line in the program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if x{_i_} &amp;gt; ' ' then&lt;/STRONG&gt; do _n_=1 to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The counts for the missing values will remain at zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you can get MAXCOUNT, MAXVAR, and VARNAME.&amp;nbsp; To also get MAXVALUE, you could utilize MAXVAR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;maxvalue = x{maxvar};&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 17:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269808#M269443</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-05-11T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269862#M269444</link>
      <description>&lt;P&gt;Thanks all for the various approaches. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FreelanceReinhard's code is ready to go, for the most frequent response. Thanks a lot (so that I don't need to write additional code or revise code).&lt;BR /&gt;stat_sas's code works when I want the max value and its count.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've filed away all for future reference. Thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 19:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269862#M269444</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2016-05-11T19:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269931#M269445</link>
      <description>&lt;P&gt;If your variable are Alphabeta NOT digit , try the following code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
infile cards truncover;
input id ( x1  x2  x3  x4  x5) ($) ;
cards;
1 07 04 07 07 07
2 04 05 04 04 05
3 02 02  .  03 .
4 01 01 02 02
5 01 . . .
;
run;

data want;
if _n_=1 then do;
 length key $ 40;
 declare hash h();
 declare hiter hi('h');
 h.definekey('key');
 h.definedata('key','count');
 h.definedone();
end;
 set have;
 array xx{*} $ x:;
 do i=1 to dim(xx);
  if not missing(xx{i}) then do;
   key=xx{i};
   if h.find()=0 then count+1;
    else count=1;
   h.replace();
  end;
 end;
 most_freq=0;
 do while(hi.next()=0);
  if most_freq lt count then do;
   mode=key;
   most_freq=count;
  end;
 end;
h.clear();
drop i key count ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 May 2016 02:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/269931#M269445</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-12T02:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find most frequent response across multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/270104#M269446</link>
      <description>&lt;P&gt;You are right. I thougt this is based on maximum number but this is not the case.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 17:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-most-frequent-response-across-multiple-variables/m-p/270104#M269446</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-05-12T17:27:06Z</dc:date>
    </item>
  </channel>
</rss>

