<?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 to select rows with 2 different data table with matched column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252148#M49501</link>
    <description>&lt;P&gt;Here are 3 different ways to do this.....and I am sure others may have other ways to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt = Open( "$SAMPLE_DATA/BIG CLASS.JMP" );
dt1 = dt &amp;lt;&amp;lt; Subset( Columns( Name ), Output Table Name( "1" ) );
dt1 &amp;lt;&amp;lt; Delete Rows( 15 :: 40 ); 

// Method one, read a name in dt1 and select it in dt, repeat 
// for all rows in dt1

dt &amp;lt;&amp;lt; clear rowstates;

For(i=1,i&amp;lt;= nrows(dt1),i++,
	dt &amp;lt;&amp;lt; select where(dt:name == dt1:name[i], current selection("extend"));
);

// Method 2, extract names from dt1 into a list, and then
// compare against the list for the 

dt &amp;lt;&amp;lt; clear rowstates;

nameList = dt1:name &amp;lt;&amp;lt; get values;
dt &amp;lt;&amp;lt; select where(contains(nameList,:name));

//Method 3, Update dt with dt1 and select matching rows
// this method would be the fastest on large data tables

dt &amp;lt;&amp;lt; clear rowstates;

// add a column to use as a selector
dt1 &amp;lt;&amp;lt; New Column( "selector", set each value( 1 ) );

dt &amp;lt;&amp;lt; Update( With( dt1 ), Match Columns( :name = :name ) );
dt &amp;lt;&amp;lt; select where( :selector == 1 );
dt &amp;lt;&amp;lt; delete columns( "selector" );
dt1 &amp;lt;&amp;lt; delete columns( "selector" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Mar 2020 01:02:27 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-03-13T01:02:27Z</dc:date>
    <item>
      <title>How to select rows with 2 different data table with matched column</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252142#M49499</link>
      <description>&lt;P&gt;&amp;amp;*script below don't work could you help to debug and send me a workable script? I want to realize the function that "select all rows" in dt which matched column: name in dt1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/BIG CLASS.JMP" );
dt1 = dt &amp;lt;&amp;lt; Subset( Columns( Name ), Output Table Name( "1" ) );
dt1 &amp;lt;&amp;lt; Delete Rows( 15 :: 40 ); // I want to relize the function of "select all rows that (dt:name==dt1:name) dt &amp;lt;&amp;lt; Select where( With(dt1), By Matching Columns(name==name), );
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:26:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252142#M49499</guid>
      <dc:creator>Theresa</dc:creator>
      <dc:date>2023-06-09T23:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to select rows with 2 different data table with matched column</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252148#M49501</link>
      <description>&lt;P&gt;Here are 3 different ways to do this.....and I am sure others may have other ways to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt = Open( "$SAMPLE_DATA/BIG CLASS.JMP" );
dt1 = dt &amp;lt;&amp;lt; Subset( Columns( Name ), Output Table Name( "1" ) );
dt1 &amp;lt;&amp;lt; Delete Rows( 15 :: 40 ); 

// Method one, read a name in dt1 and select it in dt, repeat 
// for all rows in dt1

dt &amp;lt;&amp;lt; clear rowstates;

For(i=1,i&amp;lt;= nrows(dt1),i++,
	dt &amp;lt;&amp;lt; select where(dt:name == dt1:name[i], current selection("extend"));
);

// Method 2, extract names from dt1 into a list, and then
// compare against the list for the 

dt &amp;lt;&amp;lt; clear rowstates;

nameList = dt1:name &amp;lt;&amp;lt; get values;
dt &amp;lt;&amp;lt; select where(contains(nameList,:name));

//Method 3, Update dt with dt1 and select matching rows
// this method would be the fastest on large data tables

dt &amp;lt;&amp;lt; clear rowstates;

// add a column to use as a selector
dt1 &amp;lt;&amp;lt; New Column( "selector", set each value( 1 ) );

dt &amp;lt;&amp;lt; Update( With( dt1 ), Match Columns( :name = :name ) );
dt &amp;lt;&amp;lt; select where( :selector == 1 );
dt &amp;lt;&amp;lt; delete columns( "selector" );
dt1 &amp;lt;&amp;lt; delete columns( "selector" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2020 01:02:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252148#M49501</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-03-13T01:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to select rows with 2 different data table with matched column</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252155#M49502</link>
      <description>thank you so much</description>
      <pubDate>Fri, 13 Mar 2020 01:20:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/252155#M49502</guid>
      <dc:creator>Theresa</dc:creator>
      <dc:date>2020-03-13T01:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to select rows with 2 different data table with matched column</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/263856#M51497</link>
      <description>&lt;P&gt;this is really nice! I used method 1.&lt;/P&gt;&lt;P&gt;I needed to copy-paste the file path of my data table for this to work. i couldnt figure out how to change the working directory so that I could just type in the file names without the whole path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 May 2020 18:23:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-rows-with-2-different-data-table-with-matched/m-p/263856#M51497</guid>
      <dc:creator>ezorlo</dc:creator>
      <dc:date>2020-05-03T18:23:11Z</dc:date>
    </item>
  </channel>
</rss>

