BookmarkSubscribeRSS Feed
christinagting0
Quartz | Level 8

I know this has been posted a ton already and I have searched the forums and google, but I still don't really understand what is happening when I get this note: The query requires remerging summary statistics back with the original data.

 

I am running this code:

 

proc sql;
create table collapsed_data_final_version as 
select *,
sum(msk_tx_yes) as msk_tx_sum,
sum(msk_cancel_tx_yes) as msk_cancel_tx_sum,
sum(msk_ca_yes) as msk_ca_sum, 
sum(msk_cancel_ca_yes) as msk_cancel_ca_sum, 
sum(msk_dc_yes) as msk_dc_sum,
sum(conc_psych_tx_yes) as conc_psych_tx_sum,
sum(conc_psych_ca_yes) as conc_psych_ca_sum,
sum (conc_psych_dc_yes) as conc_psych_dc_sum,
sum (conc_yes) as conc_sum,
sum (psych_yes) as psych_sum,
sum (surg_prog) as surg_sum
from test1
group by MRN;
quit;

can someone explain in VERY SIMPLY terms why I am getting this note and what I can do to fix this? Is this affecting my data?

 

What I want to happen with this code is that I want to create a table which sums the variables. I want to be able to keep all the other variables from the "test1" table while grouping by variable MRN.

 

thanks!

 

1 REPLY 1
Reeza
Super User

In many SQL implementations, such as Oracle or MS SQL, the query would be invalid. 

They require every item in select clause to either 1) be an aggregate function, such as max/min/mean or 2) be part of the group by clause. SAS doesn't follow this restriction. This means that if you have items not in your group by clause you may have unique records and then the summarized data from the group by clause is merged with requested data and you get your end result. I'm not sure why SAS explicitly warns you, possibly because of the difference between the SQL or so you know it's using two passes of the data anyways. 

 

Its a Note, you don't need to do anything about it. If the results are what you want, to remove the note, you would need to manually calculate your stats per MRN in a summary table and then manually merge this with your original data. 

 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 3493 views
  • 2 likes
  • 2 in conversation