<?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 find rows with the same values for any two columns in a given column? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273399#M53180</link>
    <description>&lt;P&gt;Thank Jim!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Mode( dt[i, 1::3] || [-999] ) == -999&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 18 Jun 2020 04:17:41 GMT</pubDate>
    <dc:creator>lwx228</dc:creator>
    <dc:date>2020-06-18T04:17:41Z</dc:date>
    <item>
      <title>How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273384#M53176</link>
      <description>&lt;P&gt;For example, columns 1 —— 3 here:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA\Missing Data Pattern.jmp" );
dt&amp;lt;&amp;lt;New Column("T1",formula(If(	As Column( 1 ) == As Column( 2 ) | As Column( 2 ) ==	As Column( 3 ) | As Column( 1 ) == As Column( 3 ),	1)));dt&amp;lt;&amp;lt;run formulas;Column("T1")&amp;lt;&amp;lt;deleteFormula;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-06-18_09-33.png" style="width: 766px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24681i09E407D114A76367/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-06-18_09-33.png" alt="2020-06-18_09-33.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:29:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273384#M53176</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2023-06-09T23:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273393#M53178</link>
      <description>&lt;UL&gt;&lt;LI&gt;&lt;P class="src"&gt;I tried to simplify it:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
x = dt &amp;lt;&amp;lt; Get As Matrix();
For( i = 1, i &amp;lt;= N Row( dt ), i++,
	For( j = 1, j &amp;lt;= 2, j++,
		If( x[i, j] == x[i, j + 1],
			x[i, 5] = 1;
			Break();
		)
	)
);

dt[0, 0] = x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 03:10:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273393#M53178</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-06-18T03:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273397#M53179</link>
      <description>&lt;P&gt;Here is a different take on the issue.&amp;nbsp; I am using a Mode() function to see what the mode is.&amp;nbsp; If an actual mode exists, that means that at least 2 values match, and therefore column t1 will get set to 1.&amp;nbsp; See the JSL comments for a more complete explanation.&lt;/P&gt;
&lt;P&gt;I have attached a data table that I used for testing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 10 );

dt = Current Data Table();
New Column( "t1" );
For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	// add a value to the matrix that is less
	// than any value in the data table.  If
	// the mode() function does not find an
	// actual mode, it returns the smallest
	// value from the matrix, so if that is
	// the value returned, you know there
	// are not at least 2 values that equal
	// each other in the columns
	If( Mode( dt[i, 0] || [-999] ) == -999,
		dt:t1[i] = .,
		dt:t1[i] = 1
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:01:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273397#M53179</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-06-18T04:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273399#M53180</link>
      <description>&lt;P&gt;Thank Jim!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Mode( dt[i, 1::3] || [-999] ) == -999&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 04:17:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273399#M53180</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-06-18T04:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273414#M53183</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12538"&gt;@lwx228&lt;/a&gt;, &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Just for the fun of it...&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Added&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/12538"&gt;@lwx228&lt;/a&gt;&amp;nbsp;example data to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;, see attached JMP data table JN_AdjacentPlus.jmp&lt;/LI&gt;
&lt;LI&gt;The script below is embedded in the table. The script is named "Find any rows with matching adjacent columns", actually matching values not empties.&lt;/LI&gt;
&lt;LI&gt;Note #1: This script will take any number of columns. The columns do not need to be adjacent in the data table, just change the column specification in the definition of xmat.&lt;/LI&gt;
&lt;LI&gt;Note #2: Abs(x1-x2) ensures adjacent matches return zero and all other values are &amp;gt; 0.&lt;/LI&gt;
&lt;LI&gt;Note #3: Vmin() finds the minimum of each column of a matrix. So, transpose( Vmin(transpose(Abs(x1-x2))) ) returns the row minimum of Abs(x1-x2)&lt;/LI&gt;
&lt;LI&gt;Note #4: Loc( vec ==0 ) returns the row numbers whose value is zero.&lt;/LI&gt;
&lt;LI&gt;Note #5: &lt;STRONG&gt;Jim's solution finds any match, this script finds adjacent matches.&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt; &amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt = current data table();

xmat = dt[0,1::4];

nc = ncol(xmat);
x1 = xmat[0,1::nc-1];
x2 = xmat[0,2::nc];
idx = Loc( Transpose(Vmin(Transpose(abs(x1-x2)))) == 0);

dt &amp;lt;&amp;lt; New Column("t1", numeric, continuous);
:t1[idx]=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 08:47:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273414#M53183</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2020-06-18T08:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find rows with the same values for any two columns in a given column?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273417#M53184</link>
      <description>&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-06-18_17-11.png" style="width: 766px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24685i2210ACDE9A7A8139/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-06-18_17-11.png" alt="2020-06-18_17-11.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 09:14:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-find-rows-with-the-same-values-for-any-two-columns-in-a/m-p/273417#M53184</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-06-18T09:14:44Z</dc:date>
    </item>
  </channel>
</rss>

