<?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 Joining Two Datasets Using Closest Date Match in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Joining-Two-Datasets-Using-Closest-Date-Match/m-p/49787#M28327</link>
    <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to join two datasets in JMP using a unique identifier plus a closest date match.&amp;nbsp; I have some code here that runs and is pretty close to what I need but I am having trouble with it keeping many to one matches.&amp;nbsp;&amp;nbsp;One unique identifier "EMP_ID_UID" could (or could not) have several "Transaction Dates" and multiple "MED_SCAN_DTIMES" will match one "Transaction Date" (because Transaction Date is a date that someone clocked in for their shift and naturally a busy provider will likely administer more than one medication during a 12 hour shift).&amp;nbsp; So what I need is for the join to FIRST match on "EMP_ID_UID" and THEN match the "MED_SCAN_DTIME" to the most recent "Transacation Date" and for it to allow many&amp;nbsp;&lt;SPAN&gt;"MED_SCAN_DTIME" to match a single "Transaction Date."&amp;nbsp; Right now, the code below matches the EMP_ID_UID and it does allow many transaction dates to match one EMP_ID_UID.&amp;nbsp; It also matches the closest dates BUT it will only allow one to one match of the dates.&amp;nbsp; It keeps the closest match only.&amp;nbsp; Is there a modification I can make on the join code that produce what I need?&amp;nbsp; Any thoughts or assistance will be greatly appreciated !&amp;nbsp; &amp;nbsp;Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SELECT *&lt;BR /&gt;FROM "Random Sample Trial" t1&lt;BR /&gt;LEFT OUTER JOIN "Subset of Relevent Unit Org Codes ONLY" t2&lt;BR /&gt;ON t1.EMP_ID_UID = t2.EMP_ID_UID AND t1.MED_SCAN_DTIME&amp;gt;t2.TransactionDate&lt;BR /&gt;WHERE t1.MED_SCAN_DTIME &amp;gt; t2.TransactionDate&lt;BR /&gt;GROUP BY t1.EMP_ID_UID,t1.MED_SCAN_DTIME&lt;BR /&gt;HAVING abs(t1.MED_SCAN_DTIME-t2.TransactionDate)=min(abs(t1.MED_SCAN_DTIME-t2.TransactionDate))&lt;BR /&gt;ORDER BY t1.EMP_ID_UID&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used this for a jumping off point on the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Merging-two-tables-by-choosing-the-CLOSEST-dates/m-p/191428#M3975" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Merging-two-tables-by-choosing-the-CLOSEST-dates/m-p/191428#M3975&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jan 2018 18:02:59 GMT</pubDate>
    <dc:creator>sagrim</dc:creator>
    <dc:date>2018-01-17T18:02:59Z</dc:date>
    <item>
      <title>Joining Two Datasets Using Closest Date Match</title>
      <link>https://community.jmp.com/t5/Discussions/Joining-Two-Datasets-Using-Closest-Date-Match/m-p/49787#M28327</link>
      <description>&lt;P&gt;Hello all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to join two datasets in JMP using a unique identifier plus a closest date match.&amp;nbsp; I have some code here that runs and is pretty close to what I need but I am having trouble with it keeping many to one matches.&amp;nbsp;&amp;nbsp;One unique identifier "EMP_ID_UID" could (or could not) have several "Transaction Dates" and multiple "MED_SCAN_DTIMES" will match one "Transaction Date" (because Transaction Date is a date that someone clocked in for their shift and naturally a busy provider will likely administer more than one medication during a 12 hour shift).&amp;nbsp; So what I need is for the join to FIRST match on "EMP_ID_UID" and THEN match the "MED_SCAN_DTIME" to the most recent "Transacation Date" and for it to allow many&amp;nbsp;&lt;SPAN&gt;"MED_SCAN_DTIME" to match a single "Transaction Date."&amp;nbsp; Right now, the code below matches the EMP_ID_UID and it does allow many transaction dates to match one EMP_ID_UID.&amp;nbsp; It also matches the closest dates BUT it will only allow one to one match of the dates.&amp;nbsp; It keeps the closest match only.&amp;nbsp; Is there a modification I can make on the join code that produce what I need?&amp;nbsp; Any thoughts or assistance will be greatly appreciated !&amp;nbsp; &amp;nbsp;Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SELECT *&lt;BR /&gt;FROM "Random Sample Trial" t1&lt;BR /&gt;LEFT OUTER JOIN "Subset of Relevent Unit Org Codes ONLY" t2&lt;BR /&gt;ON t1.EMP_ID_UID = t2.EMP_ID_UID AND t1.MED_SCAN_DTIME&amp;gt;t2.TransactionDate&lt;BR /&gt;WHERE t1.MED_SCAN_DTIME &amp;gt; t2.TransactionDate&lt;BR /&gt;GROUP BY t1.EMP_ID_UID,t1.MED_SCAN_DTIME&lt;BR /&gt;HAVING abs(t1.MED_SCAN_DTIME-t2.TransactionDate)=min(abs(t1.MED_SCAN_DTIME-t2.TransactionDate))&lt;BR /&gt;ORDER BY t1.EMP_ID_UID&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used this for a jumping off point on the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Merging-two-tables-by-choosing-the-CLOSEST-dates/m-p/191428#M3975" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Merging-two-tables-by-choosing-the-CLOSEST-dates/m-p/191428#M3975&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 18:02:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Joining-Two-Datasets-Using-Closest-Date-Match/m-p/49787#M28327</guid>
      <dc:creator>sagrim</dc:creator>
      <dc:date>2018-01-17T18:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: Joining Two Datasets Using Closest Date Match</title>
      <link>https://community.jmp.com/t5/Discussions/Joining-Two-Datasets-Using-Closest-Date-Match/m-p/49981#M28433</link>
      <description>&lt;P&gt;Just checking the details.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you have:&lt;/P&gt;
&lt;P&gt;one table of clock in and out times for all the providers where the ID is the unique identifier&lt;/P&gt;
&lt;P&gt;another table with ID's and SCAN times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the end It looks like you want to be able to see which (or how many) SCAN times happened during each clock in-out interval for each ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that close?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 21:22:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Joining-Two-Datasets-Using-Closest-Date-Match/m-p/49981#M28433</guid>
      <dc:creator>Byron_JMP</dc:creator>
      <dc:date>2018-01-22T21:22:38Z</dc:date>
    </item>
  </channel>
</rss>

