<?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: selecting and ordering the ID with max rows count in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574898#M75436</link>
    <description>&lt;P&gt;In &lt;A href="https://communities.sas.com/t5/SAS-Programming/Top-N-rows-per-by-group/td-p/172659" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Top-N-rows-per-by-group/td-p/172659&lt;/A&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt; suggested using proc sort and proc rank.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jul 2019 10:07:09 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-07-19T10:07:09Z</dc:date>
    <item>
      <title>selecting and ordering the ID with max rows count</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574886#M75433</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I would like to perform a query to select top 3 ID's that have max row counts,&lt;BR /&gt;&lt;BR /&gt;I have found that it's possible to do with this query :&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
create &lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; want as
&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; id&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as cnt &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; have &lt;SPAN class="token keyword"&gt;group&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; id_user&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;
having cnt&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;cnt&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I would like to select &lt;STRONG&gt;top 3 ID&lt;/STRONG&gt;' s that have the max count of rows of variable &lt;STRONG&gt;Name&lt;/STRONG&gt; ( attached image) , the ID 1001 must come first , the 1002 second and 1004 third.&lt;BR /&gt;&lt;BR /&gt;Anyone have an idea to that ?&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="countrow_order.jpg" style="width: 323px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31139i71888ACAD1656C13/image-size/large?v=v2&amp;amp;px=999" role="button" title="countrow_order.jpg" alt="countrow_order.jpg" /&gt;&lt;/span&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 08:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574886#M75433</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T08:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: selecting and ordering the ID with max rows count</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574891#M75434</link>
      <description>&lt;P&gt;Why would ID=1004 and not 1005 be in the data? They both appear once?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 09:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574891#M75434</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-19T09:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: selecting and ordering the ID with max rows count</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574892#M75435</link>
      <description>&lt;P&gt;yes,&lt;/P&gt;&lt;P&gt;we can add them,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the idea is to get top 3 ,&amp;nbsp;&lt;/STRONG&gt;I don't need others, &lt;STRONG&gt;but&lt;/STRONG&gt; ordering by variables count could also be an option.... so I can srroll trhough them all from top...&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 09:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574892#M75435</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T09:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: selecting and ordering the ID with max rows count</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574898#M75436</link>
      <description>&lt;P&gt;In &lt;A href="https://communities.sas.com/t5/SAS-Programming/Top-N-rows-per-by-group/td-p/172659" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Top-N-rows-per-by-group/td-p/172659&lt;/A&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt; suggested using proc sort and proc rank.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 10:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/selecting-and-ordering-the-ID-with-max-rows-count/m-p/574898#M75436</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-19T10:07:09Z</dc:date>
    </item>
  </channel>
</rss>

