<?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: Write a function to join data tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747305#M92743</link>
    <description>&lt;P&gt;&lt;BR /&gt;final_data_table = DataTable("Target Table");&lt;BR /&gt;dt = {DataTable("Annotated data")};&lt;BR /&gt;&lt;BR /&gt;I got it to work! the problem was after preprocessing, the dt actually became a datatable stored in a list. change dt to dt[1] resolved the issue.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2024 16:36:59 GMT</pubDate>
    <dc:creator>DivisiveEagle45</dc:creator>
    <dc:date>2024-04-16T16:36:59Z</dc:date>
    <item>
      <title>Write a function to join data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747229#M92714</link>
      <description>&lt;P&gt;I was trying to write a function to join dt2 to dt1, however, I cannot get it to work at all... The error I got is "Name Unresolved: TrimTable at row 1 in access or evaluation of 'TrimTable' , TrimTable( dt1[1] ) /*###*/"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much appreciated for the help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;join_data_table = Function({dt1, dt2},
	{Default Local},
	dt_1 = TrimTable(dt1[1]);
	dt_2 = TrimTable(dt2[1]);
	dt_1 &amp;lt;&amp;lt; Join(
		With(dt_2),
		Merge Same Name Columns,
		By Matching Columns(:"Seq No"n = :Seq No),
		Drop multiples(1, 0),
		Include Nonmatches(1, 0),
		Preserve main table order(1)
	);

	Return(dt1);

);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2024 10:58:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747229#M92714</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-16T10:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: Write a function to join data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747242#M92722</link>
      <description>&lt;P&gt;What is dt1 supposed to contains? What does TrimTable do? Could be that TrimTable() function is missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you want something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

join_data_table = Function({dt1, dt2}, {Default Local},
	dt = dt1 &amp;lt;&amp;lt; Join(
		With(dt2),
		Merge Same Name Columns,
		By Matching Columns(:name = :name), // Seq No changed to Name
		Drop multiples(1, 0),
		Include Nonmatches(1, 0),
		Preserve main table order(1)
	);
	
	return(dt);
);

dt_bc = Open("$SAMPLE_DATA/Big Class.jmp");
dt_bcf = Open("$SAMPLE_DATA/Big Class Families.jmp");

join_data_table(dt_bc, dt_bcf);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2024 11:02:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747242#M92722</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-16T11:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Write a function to join data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747302#M92741</link>
      <description>&lt;P&gt;Thank you so much. It is very interesting that the script you gave to me works on the examples but does not work on my data tables. The dt1 is suppose to be a target table and dt2 is a processed data table, I want to join dt2 to dt1 based on column name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With your script, this is the error:&amp;nbsp;Join with Data Table unknown at row 1 in access or evaluation of 'With' , With( dt2 ) /*###*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both dt1 and dt2 were open.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if any more info is needed.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 16:27:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747302#M92741</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-16T16:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Write a function to join data tables</title>
      <link>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747305#M92743</link>
      <description>&lt;P&gt;&lt;BR /&gt;final_data_table = DataTable("Target Table");&lt;BR /&gt;dt = {DataTable("Annotated data")};&lt;BR /&gt;&lt;BR /&gt;I got it to work! the problem was after preprocessing, the dt actually became a datatable stored in a list. change dt to dt[1] resolved the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 16:36:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Write-a-function-to-join-data-tables/m-p/747305#M92743</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-16T16:36:59Z</dc:date>
    </item>
  </channel>
</rss>

