DATA Step, Macro, Functions and more

The query requires remerging summary statistics back with the original data

Reply
Contributor
Posts: 55

The query requires remerging summary statistics back with the original data

25         
26         proc sql noprint;
27         	create table armcd1 as
28         	 select distinct a.usubjid,a.arm,a.armcd,a.rfstdtc,a.sex, b.visit as vis1, b.visitnum as vis1num, b.svstdtc as vis1dtc
29         	 from armcd0 a left join
30         	  (select distinct usubjid, visit, visitnum, svstdtc
31         	   from sd.sv where visit='VISIT 1'
32         	   group by usubjid, visit having svstdtc=min(svstdtc)) b
33         	 on a.usubjid=b.usubjid
34         	 order by usubjid;

How to get rid of this note? 

Super User
Posts: 10,273

Re: The query requires remerging summary statistics back with the original data

When you use group by and a summary function (like min()), but use variables in the select that are not in the group by and not summarized in some way, you get this note. And you get no reduction of the number of observations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,599

Re: The query requires remerging summary statistics back with the original data

[ Edited ]

Something like:

proc sql noprint;
  create table armcd1 as
  select distinct a.usubjid,
                  a.arm,
                  a.armcd,
                  a.rfstdtc,
                  a.sex, 
                  b.visit as vis1, 
                  b.visitnum as vis1num, 
                  b.svstdtc as vis1dtc
  from armcd0 a 
  left join (select usubjid, visit, visitnum, svstdtc
             from (select * from sd.sv where visit='VISIT 1')
             group by usubjid, visit, visitnum having svstdtc=min(svstdtc)) b
  on a.usubjid=b.usubjid;
quit;

But its really hard to give any good advice, I have no test data to run against, have to have something to run against.  

I would simplify it out to a proc sort, and a datastep merge.

Also, what is the point of grabbing visit and visitnum?  They will always be VISIT 1, and 1?

PROC Star
Posts: 1,822

Re: The query requires remerging summary statistics back with the original data

options  NONOTES;

 

Ask a Question
Discussion stats
  • 3 replies
  • 107 views
  • 0 likes
  • 4 in conversation