<?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: Iterating Through two Data Tables of Different Sizes &amp;amp; Comparing for Matching Values in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/60227#M32849</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I made a slight error in my previous pseudo code example,&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;dtShort:Compare Column[i] &amp;gt; dtLong:Compare Column&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Needs to be reversed in logic for it to work&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; dtLong:Compare Column &amp;gt; dtShort:Compare Column[i] &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Here is a working example&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dtLong = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create the short data table
dtShort = New Table( "Short",
	New Column( "Target Age", values( {12, 16} ) ),
	New Column( "Match", character, values( {"Teenager", "Young Adult"} ) )
);

// Sort the data for illustration of data not being
// in age order
dtLong &amp;lt;&amp;lt; sort( by( :Name ), replace table( 1 ) );

// Create a couple of new columns in the data table
dtLong &amp;lt;&amp;lt; New Column( "Kind Of Match", character );
dtLong &amp;lt;&amp;lt; New Column( "Count" );

// Process the data
For( i = 1, i &amp;lt;= N Rows( dtShort ), i++, 
	// Find all rows that match the Where Clause
	theRowsFound = dtLong &amp;lt;&amp;lt; get rows where( dtLong:Age &amp;gt; dtShort:Target Age[i] );
	// If some rows were found process
	If( N Rows( theRowsFound ) &amp;gt; 0, 
		// Set a value in the dtLong data table with one statement
		// that sets values in multiple rows
		dtLong:Kind Of Match[theRowsFound] = dtShort:Match[i];
		// Now set values row by row for individual rows that were found
		theCount = 1;
		For( k = 1, k &amp;lt;= N Items( theRowsFound ), K++,
			dtLong:Count[theRowsFound[k]] = theCount;
			theCount = theCount + 1;
		);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Jun 2018 12:35:13 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-06-13T12:35:13Z</dc:date>
    <item>
      <title>Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59911#M32760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;- I have two data tables in seperate jmp files, each of which has one column.&lt;/P&gt;&lt;P&gt;- One table is 8 rows long whilst the other is 6440 rows long.&lt;/P&gt;&lt;P&gt;- &amp;nbsp;My aim is to go through each of the values in the 8-row table and compare them to every value in the 6440-row table to see if they match.&lt;/P&gt;&lt;P&gt;- I was just wondering how I could go about doing this because I want to iterate through both tables but they are different sizes. I was thinking of using a nested for loop but I'm not too sure.&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:13:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59911#M32760</guid>
      <dc:creator>Jaz</dc:creator>
      <dc:date>2018-06-11T13:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59912#M32761</link>
      <description>&lt;P&gt;I believe the easiest way to do this would be to let JMP do the work for you.&amp;nbsp; If you Join the tables into a new table, you can have JMP create a new column called Match flag, which will tell you if a match was found or not&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables==&amp;gt;Join&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:18:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59912#M32761</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-11T13:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59914#M32763</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;How would you suggest going about the problem if I wanted to check if the value in the 8-row table is&amp;nbsp;&lt;EM&gt;greater &lt;/EM&gt;than the value in the 6440-row table?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:30:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59914#M32763</guid>
      <dc:creator>Jaz</dc:creator>
      <dc:date>2018-06-11T13:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59922#M32770</link>
      <description>&lt;P&gt;Here is how I would process it.......&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// This is pseudo code, but it will give you an idea of the flow

dtShort = Open( "&amp;lt;your short data table&amp;gt;" );
dtLong = Open( "&amp;lt;your long data table&amp;gt;" );

For( i = 1, i &amp;lt;= N Rows( dtShort ), i++,
	theRowsFound = dtLong &amp;lt;&amp;lt; get rows where( dtShort:Compare Column[i] &amp;gt; dtLong:Compare Column );
	If( N Rows( theRowsFound ) &amp;gt; 0, 
		// Do your processing
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 13:52:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/59922#M32770</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-11T13:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/60222#M32844</link>
      <description>&lt;P&gt;Thanks for the quick reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the following part:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;dtLong : Compare Column &lt;/PRE&gt;&lt;P&gt;Do you mind explaining how I could access all the values in a column without having to reference to each subscript/index of the column?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 09:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/60222#M32844</guid>
      <dc:creator>Jaz</dc:creator>
      <dc:date>2018-06-13T09:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating Through two Data Tables of Different Sizes &amp; Comparing for Matching Values</title>
      <link>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/60227#M32849</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I made a slight error in my previous pseudo code example,&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;dtShort:Compare Column[i] &amp;gt; dtLong:Compare Column&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Needs to be reversed in logic for it to work&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; dtLong:Compare Column &amp;gt; dtShort:Compare Column[i] &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Here is a working example&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dtLong = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Create the short data table
dtShort = New Table( "Short",
	New Column( "Target Age", values( {12, 16} ) ),
	New Column( "Match", character, values( {"Teenager", "Young Adult"} ) )
);

// Sort the data for illustration of data not being
// in age order
dtLong &amp;lt;&amp;lt; sort( by( :Name ), replace table( 1 ) );

// Create a couple of new columns in the data table
dtLong &amp;lt;&amp;lt; New Column( "Kind Of Match", character );
dtLong &amp;lt;&amp;lt; New Column( "Count" );

// Process the data
For( i = 1, i &amp;lt;= N Rows( dtShort ), i++, 
	// Find all rows that match the Where Clause
	theRowsFound = dtLong &amp;lt;&amp;lt; get rows where( dtLong:Age &amp;gt; dtShort:Target Age[i] );
	// If some rows were found process
	If( N Rows( theRowsFound ) &amp;gt; 0, 
		// Set a value in the dtLong data table with one statement
		// that sets values in multiple rows
		dtLong:Kind Of Match[theRowsFound] = dtShort:Match[i];
		// Now set values row by row for individual rows that were found
		theCount = 1;
		For( k = 1, k &amp;lt;= N Items( theRowsFound ), K++,
			dtLong:Count[theRowsFound[k]] = theCount;
			theCount = theCount + 1;
		);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 12:35:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Iterating-Through-two-Data-Tables-of-Different-Sizes-amp/m-p/60227#M32849</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-06-13T12:35:13Z</dc:date>
    </item>
  </channel>
</rss>

