<?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: Full Outer Join of Two Tables by Timestamp within 5 Minutes of Each Other in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63807#M34143</link>
    <description>&lt;P&gt;You could create a formula column in each data table that rounds your timestamp column to the nearest 5 minutes and then use those columns for the join.&amp;nbsp;In JMP 14 if you right-click the header of your timestamp column, then select New Formula Column-&amp;gt;Transform-&amp;gt;Round..., you'll be presented with a dialog box giving you the option to round up, down, or to the nearest time increment that you want.&amp;nbsp; If you don't have JMP 14, the formula to round to the nearest 5 minute interval would look something like this:&lt;/P&gt;
&lt;P&gt;Round(&amp;nbsp;:Timestamp / 300 ) * 300&lt;/P&gt;
&lt;P&gt;(Note that 300 is the number of seconds in 5 minutes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Tables-&amp;gt;JMP Query Builder (or Tables-&amp;gt;Join) dialog has options for keeping non-matches and creating a Match Flag column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 19:11:22 GMT</pubDate>
    <dc:creator>jerry_cooper</dc:creator>
    <dc:date>2018-07-24T19:11:22Z</dc:date>
    <item>
      <title>Full Outer Join of Two Tables by Timestamp within 5 Minutes of Each Other</title>
      <link>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63773#M34113</link>
      <description>&lt;P&gt;I have two tables that I want to join by a timestamp, however, the timestamps are not recorded at the exact same time. Therefore, I wish to join any timestamps that are within 5 minutes of each other. If the timestamp does not have a matching timestamp in the other table,&amp;nbsp;I still wish to keep the row data. Is there an easy way to do this in JSL?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 13:53:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63773#M34113</guid>
      <dc:creator>twillkickers</dc:creator>
      <dc:date>2018-07-24T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Full Outer Join of Two Tables by Timestamp within 5 Minutes of Each Other</title>
      <link>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63805#M34141</link>
      <description>&lt;P&gt;There is not a builtin platform that will do a join with fuzzy matching as you have stated what you need.&amp;nbsp; However, JSL can be used to get what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a rough example of one way to script your request&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
// Create sample data tables
dt1 = New Table( "Data Table 1",
	Add Rows( 100 ),
	New Column( "DateTime",
		Numeric,
		"Continuous",
		Format( "m/d/y h:m", 19 ),
		Input Format( "m/d/y h:m" ),
		Formula( Today() + Row() * In Minutes( 5 ) ),
		Set Selected
	)
);
dt1 &amp;lt;&amp;lt; run formulas;
dt1:DateTime &amp;lt;&amp;lt; delete formula;
dt2 = dt1 &amp;lt;&amp;lt; Subset(
	Sampling Rate( 0.25 ),
	Selected columns only( 0 ),
	output table name( "Data Table 2" ),
	link to original table( 0 )
);
Current Data Table( dt2 );
For Each Row( :DateTime = :DateTime + In Minutes( Random Uniform( -100, 100 ) ) );
dt2 &amp;lt;&amp;lt; sort( by( :DateTime ), order( ascending ), replace table( 1 ) );

// Create a column in data table 1 for reference
dt1 &amp;lt;&amp;lt; New Column( "RowNum", formula( Row() ) );
dt1:RowNum &amp;lt;&amp;lt; delete formula;

// Create in data table 2 a column that will hold the row to join to
dt2 &amp;lt;&amp;lt; New Column( "Match Row" );

// Loop through data table 2 and find the rows in the first table that match
For( i = 1, i &amp;lt;= N Rows( dt2 ), i++,
	checkVal = dt2:DateTime[i];
	theRows = dt1 &amp;lt;&amp;lt; get rows where(
		:Datetime &amp;gt; checkVal - In Minutes( 5 ) &amp;amp; :DateTime &amp;lt; checkVal + In Minutes( 5 )
	);
	If( N Rows( theRows ) &amp;gt; 0,
		minList = {};
		For( k = 1, k &amp;lt;= N Rows( theRows ), k++,
			Insert Into( minList, Abs( dt1:DateTime[theRows[k]] - checkVal ) )
		);
		dt2:Match Row[i] = theRows[Loc( minList, Min( minList ) )];
	,
		dt2:Match Row[i] = 0
	);
);

// Join the tables
dt3 = dt1 &amp;lt;&amp;lt; Join(
	With( dt2 ),
	Merge Same Name Columns,
	By Matching Columns( :RowNum = :Match Row ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 1, 1 ),
	Preserve main table order( 1 ),
	output table name("Final Table")
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Jul 2018 20:00:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63805#M34141</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-24T20:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Full Outer Join of Two Tables by Timestamp within 5 Minutes of Each Other</title>
      <link>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63807#M34143</link>
      <description>&lt;P&gt;You could create a formula column in each data table that rounds your timestamp column to the nearest 5 minutes and then use those columns for the join.&amp;nbsp;In JMP 14 if you right-click the header of your timestamp column, then select New Formula Column-&amp;gt;Transform-&amp;gt;Round..., you'll be presented with a dialog box giving you the option to round up, down, or to the nearest time increment that you want.&amp;nbsp; If you don't have JMP 14, the formula to round to the nearest 5 minute interval would look something like this:&lt;/P&gt;
&lt;P&gt;Round(&amp;nbsp;:Timestamp / 300 ) * 300&lt;/P&gt;
&lt;P&gt;(Note that 300 is the number of seconds in 5 minutes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Tables-&amp;gt;JMP Query Builder (or Tables-&amp;gt;Join) dialog has options for keeping non-matches and creating a Match Flag column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 19:11:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Full-Outer-Join-of-Two-Tables-by-Timestamp-within-5-Minutes-of/m-p/63807#M34143</guid>
      <dc:creator>jerry_cooper</dc:creator>
      <dc:date>2018-07-24T19:11:22Z</dc:date>
    </item>
  </channel>
</rss>

