<?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 MAX Help in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26938#M6193</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; So I should have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where mbr_id&amp;gt;0&lt;/P&gt;&lt;P&gt;group by mbr_id, prov_id, prov_row_eff_dt);&lt;/P&gt;&lt;P&gt;order by mbr_id;&lt;/P&gt;&lt;P&gt;disconnect from odbc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Mar 2012 19:28:59 GMT</pubDate>
    <dc:creator>tmm</dc:creator>
    <dc:date>2012-03-09T19:28:59Z</dc:date>
    <item>
      <title>MAX Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26935#M6190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am connecting to a DB2 server and trying to run this query:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect odbc (dsn);&lt;/P&gt;&lt;P&gt;create table claims as select * from connection to odbc&lt;/P&gt;&lt;P&gt;(select distinct&lt;/P&gt;&lt;P&gt;mbr_id,&lt;/P&gt;&lt;P&gt;prov_mpin,&lt;/P&gt;&lt;P&gt;prov_id,&lt;/P&gt;&lt;P&gt;(max(prov_row_eff_dt)) as prov_eff_dt&lt;/P&gt;&lt;P&gt;from co.table&lt;/P&gt;&lt;P&gt;where mbr_id&amp;gt;0);&lt;/P&gt;&lt;P&gt;order by mbr_id;&lt;/P&gt;&lt;P&gt;disconnect from odbc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;an expression starting with prov_id specified in select clause, having clause or order by clause is not specified in the group by or the select clause &lt;/P&gt;&lt;P&gt;having clause or oder by clause with a column function and no group by clause is specified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I moved the prov_id to above the prov_mpin and then I get the same error but it relates to prov_mpin. so that tells me something is wrong with the max statement. if i taked the max out and just put in prov_row_eff_dt as prov_eff_dt the query runs. So something I am doing is not right with just that max portion. I tried removing the () around the max and that did not work. I am trying to get the max date of the prov_row_eff_dt so I get the newest prov_id.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26935#M6190</guid>
      <dc:creator>tmm</dc:creator>
      <dc:date>2012-03-09T19:02:52Z</dc:date>
    </item>
    <item>
      <title>MAX Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26936#M6191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use max(), min(), sum(), count(), freq, n, range, nmiss, std and many many others, which are so called summary functions, you HAVE to use 'group by' at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26936#M6191</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T19:09:25Z</dc:date>
    </item>
    <item>
      <title>MAX Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26937#M6192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As an add on to Hai.Kuo comments, if you're using GROUP BY in SQL pass through you'll also have to explicitly remerge back all other fields you want that aren't in the Group BY statement or in a summary function because of SQL restrictions. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26937#M6192</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-03-09T19:25:54Z</dc:date>
    </item>
    <item>
      <title>MAX Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26938#M6193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; So I should have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where mbr_id&amp;gt;0&lt;/P&gt;&lt;P&gt;group by mbr_id, prov_id, prov_row_eff_dt);&lt;/P&gt;&lt;P&gt;order by mbr_id;&lt;/P&gt;&lt;P&gt;disconnect from odbc;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26938#M6193</guid>
      <dc:creator>tmm</dc:creator>
      <dc:date>2012-03-09T19:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: MAX Help</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26939#M6194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think so.&amp;nbsp; Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; connect odbc (dsn);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; create table claims as &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; select * from connection to odbc (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select mbr_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , prov_mpin&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , prov_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , max(prov_row_eff_dt) as prov_eff_dt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp; co.table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp; mbr_id &amp;gt; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by 1,2,3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; order by mbr_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp; disconnect from odbc;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I reformatted your query to make it easier to read. I removed the DISTINCT keyword because I don't think it is needed, and I used column references (1,2,3) in the GROUP BY clause, which I'm pretty sure will work.&amp;nbsp; I also deleted a stray semi-colon from your example code (in front of your ORDER BY clause). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 21:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/MAX-Help/m-p/26939#M6194</guid>
      <dc:creator>BobD</dc:creator>
      <dc:date>2012-03-09T21:18:33Z</dc:date>
    </item>
  </channel>
</rss>

