<?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 the Max Group SAS SQL. in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186332#M4370</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;Hai.kuo,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;Your solution is very efficient and I all I need for this solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;I noticed that the order by block with sub queries seems to cause errors.&amp;nbsp; I was attempting to use an into statement with the order by block.&amp;nbsp; Even if the order by solution worked in this particular case the having is much better.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;When I use the into block it automatically selects the top record so if there are two records with the same total I don’t have to worry.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Feb 2015 18:46:19 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2015-02-27T18:46:19Z</dc:date>
    <item>
      <title>Selecting the Max Group SAS SQL.</title>
      <link>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186330#M4368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;I am trying to select the group with the maximum of a value.&amp;nbsp; An example of how do this in Oracle is below.&amp;nbsp; SQL server also allows this using the first(column) method.&amp;nbsp; SAS SQL does not include either of these two methods.&amp;nbsp; Do I need to write a self join to do this in SAS?&amp;nbsp; I would strongly rather not write a self-join due to it being processor inefficient.&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;SELECT degree_level, total&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(*) as total, degree_level &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from enrollment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where academic_period= '201410' and college = 'MD'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by degree_level&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by total desc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where rownum =1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2015 17:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186330#M4368</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-02-27T17:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the Max Group SAS SQL.</title>
      <link>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186331#M4369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This comes close if you don't have multiple same max total, &lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp; from &lt;/P&gt;&lt;P&gt;&amp;nbsp; ( select count(*) as total, degree_level &lt;/P&gt;&lt;P&gt;&amp;nbsp; from enrollment&lt;/P&gt;&lt;P&gt;&amp;nbsp; where academic_period= '201410' and college = 'MD'&lt;/P&gt;&lt;P&gt;&amp;nbsp; group by degree_level&lt;/P&gt;&lt;P&gt;/* order by total desc*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; ) &lt;/P&gt;&lt;P&gt;/* werhe rownum=1;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; having total = max(total);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to get the EXACT the same, you would have to resort to undocumented MONOTONIC(). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2015 18:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186331#M4369</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-02-27T18:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting the Max Group SAS SQL.</title>
      <link>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186332#M4370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;Hai.kuo,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;Your solution is very efficient and I all I need for this solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;I noticed that the order by block with sub queries seems to cause errors.&amp;nbsp; I was attempting to use an into statement with the order by block.&amp;nbsp; Even if the order by solution worked in this particular case the having is much better.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-family: Arial, sans-serif; color: black; background-position: initial;"&gt;When I use the into block it automatically selects the top record so if there are two records with the same total I don’t have to worry.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2015 18:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Selecting-the-Max-Group-SAS-SQL/m-p/186332#M4370</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-02-27T18:46:19Z</dc:date>
    </item>
  </channel>
</rss>

