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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 3966 views
  • 0 likes
  • 4 in conversation