<?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: Table Update with get rows in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256501#M50387</link>
    <description>Thanks, this works well, also for a high amount of rows.</description>
    <pubDate>Tue, 07 Apr 2020 08:55:02 GMT</pubDate>
    <dc:creator>TWE</dc:creator>
    <dc:date>2020-04-07T08:55:02Z</dc:date>
    <item>
      <title>Table Update with get rows</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256350#M50363</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two tables with &amp;gt; 50k rows and 5 -10 columns and I want to update the first table (dt1) with values from the second table (dt2). I dont want to use loops because it could take a lot of time with rows &amp;gt; 50k. The JSL "update" function works well but I need also the matched rows in dt2 for further use.&lt;/P&gt;&lt;P&gt;To show what I mean I used the "update" example from "script index" and add the name MIKE with height, weight, rank and code. I need a list with row number of matched rows. For that example it would be {1, 2, 3} because MIKE doesnt exists in dt1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = New Table( "Little Class",
	Add Rows( 3 ),
	New Column( "name", Character, Nominal, Set Values( {"KATIE", "ALFRED", "HENRY", "MIKE"} ) ),
	New Column( "height", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "weight", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "RANK", Continuous, Set Values( [3, 1, 2, 9] ) ),
	New Column( "CODE", Continuous, Set Values( [0, 1, 1, 8] ) )
);
dt1 &amp;lt;&amp;lt; Update(
	With( Data Table( "Little Class" ) ),
	Match Columns( :name = :name ),
	Add columns from Update table( {:RANK} ),
	Replace columns in Main Table( {:height} )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 18:08:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256350#M50363</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2020-04-06T18:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update with get rows</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256368#M50365</link>
      <description>&lt;P&gt;Here's one way that might work for you assuming name acts as a unique identifier:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = New Table( "Little Class",
	Add Rows( 3 ),
	New Column( "name", Character, Nominal, Set Values( {"KATIE", "ALFRED", "HENRY", "MIKE"} ) ),
	New Column( "height", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "weight", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "RANK", Continuous, Set Values( [3, 1, 2, 9] ) ),
	New Column( "CODE", Continuous, Set Values( [0, 1, 1, 8] ) )
);
dt1 &amp;lt;&amp;lt; Update(
	With( Data Table( "Little Class" ) ),
	Match Columns( :name = :name ),
	Add columns from Update table( {:RANK} ),
	Replace columns in Main Table( {:height} )
);

//Get names as associative arrays
names1 = Associative Array(dt1:name &amp;lt;&amp;lt; Get values);
names2 = Associative Array(dt2:name &amp;lt;&amp;lt; Get Values);

//Get the intersection (replaces names1)
names1 &amp;lt;&amp;lt; Intersect(names2);

//Get intersection names as List
intersection = names1 &amp;lt;&amp;lt; Get Keys;

//Find rows
update_rows = dt2 &amp;lt;&amp;lt; Get Rows Where(contains(intersection, :name)&amp;gt;0);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 18:27:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256368#M50365</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2020-04-06T18:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update with get rows</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256372#M50366</link>
      <description>&lt;P&gt;I suggest that you use a Join instead of the Update.&amp;nbsp; If setup correctly, it will work like the Update, but it will add new rows.&amp;nbsp; It also will provide you with a column that will indicate which rows were added.&lt;/P&gt;
&lt;P&gt;The drawback is that it creates a new data table, but with a couple of statements, that can be dealt with, and it will look and feel just like an update had been done.&amp;nbsp; Look at the code below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = New Table( "Little Class",
	Add Rows( 3 ),
	New Column( "name", Character, Nominal, Set Values( {"KATIE", "ALFRED", "HENRY", "MIKE"} ) ),
	New Column( "height", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "weight", Continuous, Set Values( [999, 999, 999, 111] ) ),
	New Column( "RANK", Continuous, Set Values( [3, 1, 2, 9] ) ),
	New Column( "CODE", Continuous, Set Values( [0, 1, 1, 8] ) )
);
dt3 = dt1 &amp;lt;&amp;lt; Join(
	With( dt2),
	Merge Same Name Columns,
	By Matching Columns( :name = :name ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 1, 1 ),
	Preserve main table order( 1 )
);

name = dt1 &amp;lt;&amp;lt; get name;

close(dt1, nosave );

dt3 &amp;lt;&amp;lt; set name(name);
dt1 = dt3;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Apr 2020 18:36:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256372#M50366</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-04-06T18:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update with get rows</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256501#M50387</link>
      <description>Thanks, this works well, also for a high amount of rows.</description>
      <pubDate>Tue, 07 Apr 2020 08:55:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256501#M50387</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2020-04-07T08:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Table Update with get rows</title>
      <link>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256502#M50388</link>
      <description>Thanks, I tried this approach but for more than 50k rows it will take too long. For smaller tables this works well.</description>
      <pubDate>Tue, 07 Apr 2020 08:57:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Table-Update-with-get-rows/m-p/256502#M50388</guid>
      <dc:creator>TWE</dc:creator>
      <dc:date>2020-04-07T08:57:19Z</dc:date>
    </item>
  </channel>
</rss>

