<?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 Re: Exact match and Nearest Match for updating a table with another table in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61842#M33333</link>
    <description>&lt;P&gt;That is a method that I have used in the past, and it will run faster. But, look out for records that do not have any of the interleaved records following or preceeding them.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2018 18:18:17 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-06-28T18:18:17Z</dc:date>
    <item>
      <title>Exact match and Nearest Match for updating a table with another table</title>
      <link>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61831#M33330</link>
      <description>&lt;P&gt;I have a big data table (1M rows).&amp;nbsp; One column is serialNumber, one column is dateTime, one column is elapsedTime.&amp;nbsp; Another much smaller table&amp;nbsp;also has these columns, but the dateTime is&amp;nbsp;earlier&amp;nbsp;by an small amount (5-20 minutes) and the elapsedTime is a much more accurate value.&amp;nbsp; The small table also has lots of extra rows associated with other events at other dateTimes (I do not have an 'event' column).&amp;nbsp; I want to update the big table with the accurate elapsedTimes by matching the serialNumbers and selecting the largest dateTime less than or equal to the big table's dateTime.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will be part of a bigger script that is run daily, updating each serialNumber each day.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, my best solution is to compromise on the accuracy and just select the average elapsedTime for the entire day, and using an exact match for the dateTime column.&amp;nbsp; This will introduce an inaccuracy when the small table includes multiple events at multiple times within a given day, but "within 12 hours" is still much more accurate than the big table is presently.&lt;/P&gt;&lt;P&gt;There is another solutions using a pair of nested foreachrows loops, but that will be very slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have an idea, please just suggest it, don't worry about writing the code (yet).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:01:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61831#M33330</guid>
      <dc:creator>mann</dc:creator>
      <dc:date>2018-06-28T17:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Exact match and Nearest Match for updating a table with another table</title>
      <link>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61832#M33331</link>
      <description>&lt;P&gt;I would suggest that you use something like;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;theRows = dt2 &amp;lt;&amp;lt; select rows where(&amp;nbsp; dt2:serialNumber == dt21:serialNumber[i] &amp;amp;
dt2:dateTime &amp;lt;= dt1:dateTime );

if( N Rows( theRows ) &amp;gt; 0, targetRow = theRows[N Rows( theRows )] );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:21:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61832#M33331</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-28T17:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Exact match and Nearest Match for updating a table with another table</title>
      <link>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61833#M33332</link>
      <description>&lt;P&gt;TX, I am amazed by your speed and comprehension.&amp;nbsp; Your answer subtly fails to mention a slow for each SN loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I was finishing my post I had the beginings of this idea:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Subset the big table, selecting only the date window of the small table.&lt;/P&gt;&lt;P&gt;Concatenate the&amp;nbsp;subset table onto the small table excluding the elapsedTime column.&lt;/P&gt;&lt;P&gt;Sort the concatenated table by SN &amp;amp; dateTime&lt;/P&gt;&lt;P&gt;Fill in the missing elapsedTimes with the previous row.&lt;/P&gt;&lt;P&gt;Update the big table with the concatenated table.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:33:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61833#M33332</guid>
      <dc:creator>mann</dc:creator>
      <dc:date>2018-06-28T17:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Exact match and Nearest Match for updating a table with another table</title>
      <link>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61842#M33333</link>
      <description>&lt;P&gt;That is a method that I have used in the past, and it will run faster. But, look out for records that do not have any of the interleaved records following or preceeding them.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 18:18:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exact-match-and-Nearest-Match-for-updating-a-table-with-another/m-p/61842#M33333</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-28T18:18:17Z</dc:date>
    </item>
  </channel>
</rss>

