BookmarkSubscribeRSS Feed
paddyb
Quartz | Level 8
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? 

3 REPLIES 3
Kurt_Bremser
Super User

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 4507 views
  • 0 likes
  • 4 in conversation