<?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: How do I combine tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53086#M30041</link>
    <description>&lt;P&gt;The associative array option is quite neat and I haven't used this concept very much, and never as a kind of alternative to a join. The option using the join is great to see because that was the approach that I was trying to work out for myself, but got confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm grateful to both of you for confirming that while relatively simple, this doesn't have&amp;nbsp;a "one-step" or unique solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to both of you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2018 19:51:35 GMT</pubDate>
    <dc:creator>john_madden</dc:creator>
    <dc:date>2018-03-13T19:51:35Z</dc:date>
    <item>
      <title>How do I combine tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53075#M30031</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables, A and B. I want to write JSL that will find all the rows in A whose ID is represented one or more times in B, and then append those rows to B to yield a new table C.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, let this be A:&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Data&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Day&lt;/P&gt;&lt;/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t;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Fuchsia&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Sat&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Black&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Mon&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This seems simple, but I've confused myself as to the best way to do it. The method should scale well with respect to speed and memory for A and B tables of &amp;gt;1 million rows.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 20:16:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53075#M30031</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-03-13T20:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53082#M30037</link>
      <description>&lt;P&gt;I think this should be relatively computationally efficient, and you can don't have to do it exactly this way.&amp;nbsp; Basic idea is to create a table that is a subset of the Table A where the IDs are also in Table B.&amp;nbsp; Then concatenate the subset of A to Table B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dtA = Data Table("Table A");&lt;BR /&gt;dtB = Data Table("Table B");&lt;BR /&gt;&lt;BR /&gt;b.ID = dtB:ID &amp;lt;&amp;lt; Get Values;&lt;BR /&gt;b_ID_unique = associative array(b.ID) &amp;lt;&amp;lt; Get Keys;&lt;BR /&gt;&lt;BR /&gt;dtA &amp;lt;&amp;lt; Select Where(Contains(b_ID_unique,:ID) &amp;gt; 0);&lt;BR /&gt;&lt;BR /&gt;dtASelected = dtA &amp;lt;&amp;lt; Subset( Selected Rows );&lt;BR /&gt;&lt;BR /&gt;dtB &amp;lt;&amp;lt; Concatenate(&lt;BR /&gt; dtASelected,&lt;BR /&gt; Output Table( "Table C" )&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;Close(dtASelected, No Save);&lt;/PRE&gt;&lt;P&gt;Other approach might be to hide and exclude the data that doesn't match the criteria.&amp;nbsp; This eliminates the need to create a subset table, but the hidden and excluded data come along with the concatenation.&amp;nbsp; You could select the hidden and excluded rows and delete them, but that might not be a very robust solution if you have other rows hidden and excluded that you wouldn't want to delete.&lt;/P&gt;&lt;P&gt;Third option is make a column formula indicating if row in A has an ID that exists in B, then delete the resulting rows in C that aren't a match based on the values in that column.&lt;/P&gt;&lt;P&gt;I'm sure there are numerous other ways to skin this cat, but hopefully this will do the trick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 18:30:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53082#M30037</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-03-13T18:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53083#M30038</link>
      <description>&lt;P&gt;Here is a Join centric version of a script that will work....it should be pretty efficient&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dtA = data table("A");
dtB = data table("B");

// Create data tables with only the data required
dtAID = dtA &amp;lt;&amp;lt; Subset(invisible, selected rows(0), columns(:ID));
dtBID = dtB &amp;lt;&amp;lt; Subset(invisible, selected rows(0), columns(:ID));

// Create a data table with only IDs found in both tables
dtABID = dtAID &amp;lt;&amp;lt; Join(invisible, with(dtBID ),
	Merge Same Name Columns,
	By Matching Columns( :ID = :ID ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);

close( dtAID, nosave );
close( dtBID, nosave );

// Create a table with only 1 row for each ID found
dtSum = dtABID &amp;lt;&amp;lt; Summary(invisible, 
	Group( :ID ),
	Freq( "None" ),
	Weight( "None" )
);

// Create a data table that only has the correct IDs
// from data table A
dtAMatches = dtA &amp;lt;&amp;lt; Join(invisible, 
	with(dtSum ),
	Merge Same Name Columns,
	By Matching Columns( :ID = :ID ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);

close( dtSum, nosave );

// Delete column Match Flag and N Rows
dtAMatches &amp;lt;&amp;lt; delete columns("Match Flag", "N Rows");

// Concatenate table B with the matched data from table A
dtFinal = dtB &amp;lt;&amp;lt; Concatenate( dtAMatches );

close( dtAMatches, nosave );

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:02:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53083#M30038</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-13T19:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53086#M30041</link>
      <description>&lt;P&gt;The associative array option is quite neat and I haven't used this concept very much, and never as a kind of alternative to a join. The option using the join is great to see because that was the approach that I was trying to work out for myself, but got confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm grateful to both of you for confirming that while relatively simple, this doesn't have&amp;nbsp;a "one-step" or unique solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to both of you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:51:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53086#M30041</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-03-13T19:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I combine tables</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53087#M30042</link>
      <description>&lt;P&gt;The associative array option is quite neat and I haven't used this concept very much, and never as a kind of alternative to a join. The option using the join is great to see because that was the approach that I was trying to work out for myself, but got confused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm grateful to both of you for confirming that while relatively straightforward, this doesn't have&amp;nbsp;a "one-step" or unique solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to both of you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 19:52:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-combine-tables/m-p/53087#M30042</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2018-03-13T19:52:49Z</dc:date>
    </item>
  </channel>
</rss>

