<?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: Simple proc freq of a variable limiting to top 5 on SAS studio in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353155#M2376</link>
    <description>&lt;P&gt;You can also use the method that Astounding mentions to graph the top categories. See &lt;A href="http://blogs.sas.com/content/iml/2013/01/09/create-a-bar-chart-with-only-a-few-categories.html" target="_self"&gt;"Create a bar chart with only a few categories."&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2017 12:11:57 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-04-25T12:11:57Z</dc:date>
    <item>
      <title>Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353120#M2374</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a massive output of a proc freq of a variable in which I want to only limit to the top 5. How do I set up the code? I used this and it seemed to not work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=janfeb.jfgmi order=freq rowlimit=5;
table finalicd10;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 08:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353120#M2374</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-25T08:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353139#M2375</link>
      <description>&lt;P&gt;SAS has to count every observation, to know what belongs in the highest 5. &amp;nbsp;So you might as well count them all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=jabfeb order=freq;&lt;/P&gt;
&lt;P&gt;tables finalicd10 / noprint out=counts;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By creating a SAS data set instead of printing the table, you now have choices. &amp;nbsp;The simplest:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set counts (obs=5);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if the 5th highest count also appears as the 6th or 7th highest count, you lose the ties. &amp;nbsp;You could instead &amp;nbsp;continue with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set counts;&lt;/P&gt;
&lt;P&gt;by descending count;&lt;/P&gt;
&lt;P&gt;if first.count and _n_ &amp;gt; 5 then stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 10:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353139#M2375</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-25T10:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353155#M2376</link>
      <description>&lt;P&gt;You can also use the method that Astounding mentions to graph the top categories. See &lt;A href="http://blogs.sas.com/content/iml/2013/01/09/create-a-bar-chart-with-only-a-few-categories.html" target="_self"&gt;"Create a bar chart with only a few categories."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 12:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353155#M2376</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-04-25T12:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353160#M2377</link>
      <description>&lt;PRE&gt;
Use SQL instead .


proc sql outobs=5;
 select air,count(*) as count
  from sashelp.air
   group by air
    order by count desc;
quit;



&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 12:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353160#M2377</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-25T12:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353183#M2378</link>
      <description>&lt;P&gt;This works! Thanks. How do I title a proc sql statement?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 13:31:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353183#M2378</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-25T13:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353191#M2379</link>
      <description>&lt;P&gt;You mean add a title or lable ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title 'xxxxxxx';

proc sql outobs=5;
 select air,count(*) as count label='xxxxx'
  from sashelp.air
   group by air
    order by count desc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 13:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353191#M2379</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-25T13:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353196#M2380</link>
      <description>That works, thanks!&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 25 Apr 2017 13:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/353196#M2380</guid>
      <dc:creator>byeh2017</dc:creator>
      <dc:date>2017-04-25T13:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/431798#M4486</link>
      <description>&lt;P&gt;Thanks so much for this code it is very helpful! How would you go about formatting a table like this. I tried using PROC TABULATE to rename the row headers etc. but I don't know how to point the PROC TAB at the new table.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 15:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/431798#M4486</guid>
      <dc:creator>spcoman</dc:creator>
      <dc:date>2018-01-29T15:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/432153#M4493</link>
      <description>&lt;P&gt;Once you assign a label to a variable, proc tabulate would print the label.&lt;/P&gt;
&lt;P&gt;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options label;&lt;/P&gt;
&lt;P&gt;proc tabulate .......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And can start a brand new session to let other know your Q,and maybe others have a better idea.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 12:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/432153#M4493</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-30T12:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/661748#M9225</link>
      <description>You can try:&lt;BR /&gt;&lt;BR /&gt;proc freq data=janfeb.jfgmi ORDER=FREQ;&lt;BR /&gt;tables make / maxlevels=5 Plots=FreqPlot;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Jun 2020 14:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/661748#M9225</guid>
      <dc:creator>dhwanipatel109</dc:creator>
      <dc:date>2020-06-17T14:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Simple proc freq of a variable limiting to top 5 on SAS studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/746801#M10012</link>
      <description>&lt;P&gt;I just stumbled upon this answer and it is by far the simplest solution, thank you so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 16:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Simple-proc-freq-of-a-variable-limiting-to-top-5-on-SAS-studio/m-p/746801#M10012</guid>
      <dc:creator>wlauzon</dc:creator>
      <dc:date>2021-06-09T16:01:25Z</dc:date>
    </item>
  </channel>
</rss>

