<?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: PROC SQL with Group By Issue in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30664#M7293</link>
    <description>When SAS tells you so, that's because it found items in the SELECT part that were neither statistics, neither mentionned in the GROUP BY part.&lt;BR /&gt;
Here you have two problems at the same time : 1) the NATIONAL_ID is typed ID in the GROUP BY (--&amp;gt; SQL won't connect both) and 2) the SNAPSHOT_DATE is neither a statistic, neither a GROUP BY element.&lt;BR /&gt;
I agree that SNAPSHOT_DATE is logically constant, since it appears in the WHERE part, but that's not taken into account by SQL.&lt;BR /&gt;
So I would try the following code :&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE d_act AS&lt;BR /&gt;
SELECT&lt;BR /&gt;
national_id&lt;BR /&gt;
,snapshot_date&lt;BR /&gt;
,Max(credit_limit_Amt) AS Cr_limit&lt;BR /&gt;
FROM dw.ACCT&lt;BR /&gt;
WHERE Snapshot_Date = '30JUN2008'D &lt;BR /&gt;
GROUP BY national_id, snapshot_date&lt;BR /&gt;
;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
    <pubDate>Fri, 11 Jul 2008 11:01:06 GMT</pubDate>
    <dc:creator>Olivier</dc:creator>
    <dc:date>2008-07-11T11:01:06Z</dc:date>
    <item>
      <title>PROC SQL with Group By Issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30663#M7292</link>
      <description>I used following PROC SQL coding to retrive data from data warehouse by ODBC method. I want to group data by customer ID. However the final outcome does not show unique ID. The SAS log mentioned that "The query requires remerging summary statistics back with the original data". Does anyone have similar issue before and know how to solve it? Thanks! &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                              PROC SQL;&lt;BR /&gt;
         		CREATE TABLE d_act AS&lt;BR /&gt;
         		SELECT&lt;BR /&gt;
       		         national_id&lt;BR /&gt;
          		        ,snapshot_date&lt;BR /&gt;
         		        ,Max(credit_limit_Amt)   AS Cr_limit&lt;BR /&gt;
        		FROM      dw.ACCT&lt;BR /&gt;
        		WHERE   Snapshot_Date  =    '30JUN2008'D     	&lt;BR /&gt;
         		GROUP BY id;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The query requires remerging summary statistics back with the original data.</description>
      <pubDate>Fri, 11 Jul 2008 10:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30663#M7292</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-11T10:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL with Group By Issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30664#M7293</link>
      <description>When SAS tells you so, that's because it found items in the SELECT part that were neither statistics, neither mentionned in the GROUP BY part.&lt;BR /&gt;
Here you have two problems at the same time : 1) the NATIONAL_ID is typed ID in the GROUP BY (--&amp;gt; SQL won't connect both) and 2) the SNAPSHOT_DATE is neither a statistic, neither a GROUP BY element.&lt;BR /&gt;
I agree that SNAPSHOT_DATE is logically constant, since it appears in the WHERE part, but that's not taken into account by SQL.&lt;BR /&gt;
So I would try the following code :&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
CREATE TABLE d_act AS&lt;BR /&gt;
SELECT&lt;BR /&gt;
national_id&lt;BR /&gt;
,snapshot_date&lt;BR /&gt;
,Max(credit_limit_Amt) AS Cr_limit&lt;BR /&gt;
FROM dw.ACCT&lt;BR /&gt;
WHERE Snapshot_Date = '30JUN2008'D &lt;BR /&gt;
GROUP BY national_id, snapshot_date&lt;BR /&gt;
;&lt;BR /&gt;
QUIT ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Fri, 11 Jul 2008 11:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30664#M7293</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-07-11T11:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL with Group By Issue</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30665#M7294</link>
      <description>Thanks Olivier for your help!</description>
      <pubDate>Sat, 12 Jul 2008 02:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-with-Group-By-Issue/m-p/30665#M7294</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-12T02:29:24Z</dc:date>
    </item>
  </channel>
</rss>

