BookmarkSubscribeRSS Feed
Doc_Duke
Rhodochrosite | Level 12
I know what I want to do, but can't figure out how to do it in the point-and-click part of EGuide.

I have hospital encounters and the all labs done (ever). I want the labs that were done closest to the admission of interest. It is, to me, a simple application of the HAVING operator in SQL, but I cant figure out how to get EGuide to do it. I don't want to create a code template because my students don't know how to write code. "t1" is the demographics+Encounter info and "t2" is the lab set.

EGuide gets me this far:
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_DEMENC AS
SELECT t1.PID,
t2.EID,
t1.Ethnicity,
t1.Gender,
t1.Race,
t1.Age,
t1.EBegin,
t1.EEnd,
t2.LabDate,
t2.LabDateTime
t2.TestCodeDescription,
t2.NumericResult,
t2.'Unit of Measure'n,
t2.AbnormalFlag
FROM DEDUCE.DEMENC t1 LEFT JOIN DEDUCE.LABS t2 ON (t1.PID = t2.PID)
GROUP BY t1.PID, t2.EID, t2.TestCodeDescription ;

I want to add
HAVING t2.LabDateTime = MIN(t2.LabDateTime)
at the end.

Is that functionality there and I just can't see it, or is a "feature" for future development? Any workaround ideas?

Thanks,
Doc
2 REPLIES 2
DerekAdams
Calcite | Level 5
Hi

You can use the the bottom box, "Filter the summarized data", on the filter tab to create your having clauses
Doc_Duke
Rhodochrosite | Level 12
Bingo. thanks.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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