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-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!

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.

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