BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!



PROC SQL;
CREATE TABLE d_act AS
SELECT
national_id
,snapshot_date
,Max(credit_limit_Amt) AS Cr_limit
FROM dw.ACCT
WHERE Snapshot_Date = '30JUN2008'D
GROUP BY id;

NOTE: The query requires remerging summary statistics back with the original data.
2 REPLIES 2
Olivier
Pyrite | Level 9
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.
Here you have two problems at the same time : 1) the NATIONAL_ID is typed ID in the GROUP BY (--> SQL won't connect both) and 2) the SNAPSHOT_DATE is neither a statistic, neither a GROUP BY element.
I agree that SNAPSHOT_DATE is logically constant, since it appears in the WHERE part, but that's not taken into account by SQL.
So I would try the following code :
[pre]
PROC SQL;
CREATE TABLE d_act AS
SELECT
national_id
,snapshot_date
,Max(credit_limit_Amt) AS Cr_limit
FROM dw.ACCT
WHERE Snapshot_Date = '30JUN2008'D
GROUP BY national_id, snapshot_date
;
QUIT ;
[/pre]
Regards.
Olivier
deleted_user
Not applicable
Thanks Olivier for your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 648 views
  • 0 likes
  • 2 in conversation