<?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 How to find 3 most frequently occurring values? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204661#M11000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I find 3 most frequently occurring values in my dataset using SAS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleksandra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jul 2015 12:53:29 GMT</pubDate>
    <dc:creator>Alexandra22</dc:creator>
    <dc:date>2015-07-16T12:53:29Z</dc:date>
    <item>
      <title>How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204661#M11000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I find 3 most frequently occurring values in my dataset using SAS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aleksandra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 12:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204661#M11000</guid>
      <dc:creator>Alexandra22</dc:creator>
      <dc:date>2015-07-16T12:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204662#M11001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From one variable or more?&amp;nbsp; You could probably use the count() function with proc sql, get counts of your values then sort them. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 13:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204662#M11001</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2015-07-16T13:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204663#M11002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming your data are in mydat and the variable you would like to know the most frequent values of is myvar, you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; /* get frequency of myvar in your data set */&lt;/P&gt;&lt;P&gt;proc freq data=mydat;&lt;/P&gt;&lt;P&gt;tables myvar / noprint out=tmp (keep=myvar count);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* sort in descending order by frequency */&lt;/P&gt;&lt;P&gt;proc sort data=tmp;&lt;/P&gt;&lt;P&gt;by descending count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* get the frequency of the third most frequent item, need to do this as there might be multiple value of myvar tied for this value; note that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; code will also work if there are fewer than 3 distinct values for myvar in your data set. */&lt;/P&gt;&lt;P&gt;data _NULL_; &lt;/P&gt;&lt;P&gt;set tmp;&lt;/P&gt;&lt;P&gt;if _n_ &amp;lt;= 3 then call symput('maxcount',count);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/* only keep observations with a frequency of maxcount or higher */&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;set tmp (where=(count &amp;gt;= &amp;amp;maxcount));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=tmp;&lt;/P&gt;&lt;P&gt;var myvar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beate&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 14:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204663#M11002</guid>
      <dc:creator>beate</dc:creator>
      <dc:date>2015-07-16T14:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204664#M11003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't need a dataset Proc Freq with the order=freq will generate a table with the most frequent at the top and provide the count at the same time. This also has an advantage of easily adding multiple, or even all variables in a data set with one pass through the data though that can create a lot of output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc freq data=haveorder=freq;&lt;/P&gt;&lt;P&gt;tables variable;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 15:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204664#M11003</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-07-16T15:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204665#M11004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And you can use a variation of &lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; 's answer to &lt;A href="http://blogs.sas.com/content/iml/2013/01/09/create-a-bar-chart-with-only-a-few-categories.html"&gt;create a bar chart of the top k categories.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 17:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204665#M11004</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-07-16T17:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to find 3 most frequently occurring values?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204666#M11005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was the technique I was looking for, &lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;, when I came up with the other post on the other fork of this thread.&amp;nbsp; If I could hand out a Correct, you'd get it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 15:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-find-3-most-frequently-occurring-values/m-p/204666#M11005</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2015-07-17T15:06:38Z</dc:date>
    </item>
  </channel>
</rss>

