<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic &amp;quot;Closest&amp;quot; match in EGuide in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14327#M2938</link>
    <description>I know what I want to do, but can't figure out how to do it in the point-and-click part of EGuide.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
EGuide gets me this far:&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
   CREATE TABLE WORK.QUERY_FOR_DEMENC AS &lt;BR /&gt;
   SELECT t1.PID, &lt;BR /&gt;
          t2.EID, &lt;BR /&gt;
          t1.Ethnicity, &lt;BR /&gt;
          t1.Gender, &lt;BR /&gt;
          t1.Race, &lt;BR /&gt;
          t1.Age, &lt;BR /&gt;
          t1.EBegin, &lt;BR /&gt;
          t1.EEnd, &lt;BR /&gt;
          t2.LabDate, &lt;BR /&gt;
          t2.LabDateTime&lt;BR /&gt;
          t2.TestCodeDescription, &lt;BR /&gt;
          t2.NumericResult, &lt;BR /&gt;
          t2.'Unit of Measure'n, &lt;BR /&gt;
          t2.AbnormalFlag&lt;BR /&gt;
      FROM DEDUCE.DEMENC t1 LEFT JOIN DEDUCE.LABS t2 ON (t1.PID = t2.PID)&lt;BR /&gt;
      GROUP BY t1.PID, t2.EID, t2.TestCodeDescription ;&lt;BR /&gt;
&lt;BR /&gt;
I want to add&lt;BR /&gt;
     HAVING t2.LabDateTime = MIN(t2.LabDateTime)&lt;BR /&gt;
at the end.&lt;BR /&gt;
&lt;BR /&gt;
Is that functionality there and I just can't see it, or is a "feature" for future development?  Any workaround ideas?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Doc</description>
    <pubDate>Mon, 21 Feb 2011 19:24:13 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2011-02-21T19:24:13Z</dc:date>
    <item>
      <title>"Closest" match in EGuide</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14327#M2938</link>
      <description>I know what I want to do, but can't figure out how to do it in the point-and-click part of EGuide.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
EGuide gets me this far:&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
   CREATE TABLE WORK.QUERY_FOR_DEMENC AS &lt;BR /&gt;
   SELECT t1.PID, &lt;BR /&gt;
          t2.EID, &lt;BR /&gt;
          t1.Ethnicity, &lt;BR /&gt;
          t1.Gender, &lt;BR /&gt;
          t1.Race, &lt;BR /&gt;
          t1.Age, &lt;BR /&gt;
          t1.EBegin, &lt;BR /&gt;
          t1.EEnd, &lt;BR /&gt;
          t2.LabDate, &lt;BR /&gt;
          t2.LabDateTime&lt;BR /&gt;
          t2.TestCodeDescription, &lt;BR /&gt;
          t2.NumericResult, &lt;BR /&gt;
          t2.'Unit of Measure'n, &lt;BR /&gt;
          t2.AbnormalFlag&lt;BR /&gt;
      FROM DEDUCE.DEMENC t1 LEFT JOIN DEDUCE.LABS t2 ON (t1.PID = t2.PID)&lt;BR /&gt;
      GROUP BY t1.PID, t2.EID, t2.TestCodeDescription ;&lt;BR /&gt;
&lt;BR /&gt;
I want to add&lt;BR /&gt;
     HAVING t2.LabDateTime = MIN(t2.LabDateTime)&lt;BR /&gt;
at the end.&lt;BR /&gt;
&lt;BR /&gt;
Is that functionality there and I just can't see it, or is a "feature" for future development?  Any workaround ideas?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Doc</description>
      <pubDate>Mon, 21 Feb 2011 19:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14327#M2938</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-02-21T19:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: "Closest" match in EGuide</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14328#M2939</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
You can use the the bottom box, "Filter the summarized data", on the filter tab to create your having clauses</description>
      <pubDate>Tue, 22 Feb 2011 01:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14328#M2939</guid>
      <dc:creator>DerekAdams</dc:creator>
      <dc:date>2011-02-22T01:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: "Closest" match in EGuide</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14329#M2940</link>
      <description>Bingo.  thanks.</description>
      <pubDate>Tue, 22 Feb 2011 15:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Closest-quot-match-in-EGuide/m-p/14329#M2940</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-02-22T15:16:18Z</dc:date>
    </item>
  </channel>
</rss>

