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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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