<?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: max 3 in proc report in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439073#M20466</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt; brings up a very good point, what if there are repeats. If there are 4 7's what would you want to see and how would you just which three to show? It may be better to use RANK in that approach, but you need to know the number of observations for that approach as well.</description>
    <pubDate>Wed, 21 Feb 2018 21:09:01 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-21T21:09:01Z</dc:date>
    <item>
      <title>max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439062#M20462</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this input and I'm trying to output only the max 3 by using proc report&amp;nbsp;&lt;/P&gt;&lt;P&gt;Top 3 Sites with highest # issues # Open Issues&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1350&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1601&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1450&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1451&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5006&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1602&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1200&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1600&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1050&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5008&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is the aimed results&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Top 3 Sites with highest # issues:&lt;/TD&gt;&lt;TD&gt;1601&lt;/TD&gt;&lt;TD&gt;1350&lt;/TD&gt;&lt;TD&gt;1450&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Open Issues:&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 20:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439062#M20462</guid>
      <dc:creator>mona4u</dc:creator>
      <dc:date>2018-02-21T20:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439066#M20463</link>
      <description>&lt;P&gt;what happens 7 is repeated&amp;nbsp; 4 times&lt;/P&gt;
&lt;P&gt;or 7 is repeated 1 time and 6 is repeated 4 times. for example&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 abc;
infile datalines dlm = '09'x;
input 	@3 Site_Number @8	numsites;
datalines;
1	1050	1
2	1200	2
3	1350	7
4	1450	7
5	1451	4
6	1600	2
7	1601	6
8	1602	6
9	5006	6
10	5008	1
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Feb 2018 20:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439066#M20463</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-21T20:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439067#M20464</link>
      <description>&lt;UL&gt;
&lt;LI&gt;Sort the data&lt;/LI&gt;
&lt;LI&gt;Use OBS= to keep only top N observations&lt;/LI&gt;
&lt;LI&gt;Use PROC REPORT/TABULATE/PRINT to display the results, as desired&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I'll leave the final formatting to you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Here's a demo using SASHELP.CLASS - using this in your demo code will help you get faster answers because a user can just run your code. It's also a good way to learn because you're separating development from implementation so you're less likely to make mistakes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%* sort descending;
proc sort data=sashelp.class out=class;
by descending height;
run;


proc tabulate data=class (obs=3); *take top 3;
class name;
var height;
table name*height=''*mean=''; *display somewhat as shown;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 20:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439067#M20464</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-21T20:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439073#M20466</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37783"&gt;@kiranv_&lt;/a&gt; brings up a very good point, what if there are repeats. If there are 4 7's what would you want to see and how would you just which three to show? It may be better to use RANK in that approach, but you need to know the number of observations for that approach as well.</description>
      <pubDate>Wed, 21 Feb 2018 21:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439073#M20466</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-21T21:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439074#M20467</link>
      <description>&lt;P&gt;I like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;solution which is clean way to do what you want to do. Another interesting way could be sql and transpose for your scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* for any top 3*/&lt;BR /&gt;proc sql outobs=3;&lt;BR /&gt;create table newtable(drop=val) as &lt;BR /&gt;select site_number, numsites,&lt;BR /&gt;(select count(distinct numsites) from abc a&lt;BR /&gt;where a.numsites &amp;gt;= b.numsites)as val&lt;BR /&gt;from abc b;&lt;BR /&gt;&lt;BR /&gt;/* for top 3 repeated*/&lt;BR /&gt;proc sql ;&lt;BR /&gt;create table newtable (drop=val) as &lt;BR /&gt;select site_number, numsites,&lt;BR /&gt;(select count(distinct numsites)&lt;BR /&gt; from abc awhere a.numsites &amp;gt;= b.numsites)as val&lt;BR /&gt; from abc bwhere calculated val le 3;&lt;BR /&gt;&lt;BR /&gt;proc transpose data =newtable out=finaltable(drop =_name_);&lt;BR /&gt;id site_number;&lt;BR /&gt;var numsites;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Feb 2018 21:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439074#M20467</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-21T21:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: max 3 in proc report</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439077#M20468</link>
      <description>&lt;P&gt;Or create both and you have the option of using rank_multiple or rank as desired. It's worth knowing how to do this anyways:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=abc; by descending numsites;

data cat;
set abc;
by descending numsites;
retain rank_multiple 0;

rank = _n_;
rank_multiple = ifn(first.numsites, rank_multiple+1, rank_multiple);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Feb 2018 21:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/max-3-in-proc-report/m-p/439077#M20468</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-21T21:18:56Z</dc:date>
    </item>
  </channel>
</rss>

