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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 631 views
  • 0 likes
  • 2 in conversation