<?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: If row column value equals any values of any array then... What is the general form of this formal? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195026#M41597</link>
    <description>&lt;P&gt;1. A matrix can only contain numeric values.&amp;nbsp; Therefore, the matrix z needs to be specified as a List, not as a Matrix&lt;/P&gt;
&lt;P&gt;2. I do not know what "cust" is.&lt;/P&gt;
&lt;P&gt;3. Is this a column formula, or open JSL code?&lt;/P&gt;
&lt;P&gt;4. Loc returns a matrix of the positions where the testing value is found in the List.&amp;nbsp; Therefore, you need to determine if more than 0 rows were returned to determine if a match has been found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are a couple of script examples that might help you out&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

// As a formula in a new column
dt &amp;lt;&amp;lt; New Column( "is present",
	formula(
		z = {"customer1", "customer2", "customer3"};
		If( N Rows( Loc( z, :Name( "Ship-To Customer" ) ) &amp;gt; 0 ),
			1,
			0
		);
	)
);

// In open JSL
z = {"customer1", "customer2", "customer3"};
For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	If( N Rows( Loc( z, :Name( "Ship-To Customer" )[i] ) ) &amp;gt; 0,
		1,
		0
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 25 Apr 2019 21:02:39 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2019-04-25T21:02:39Z</dc:date>
    <item>
      <title>If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195008#M41591</link>
      <description>&lt;P&gt;How do I write an If statement (or whatever the right function is) to evaluated when a row's column value = any value in an array?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;/P&gt;&lt;P&gt;If(&amp;nbsp; &amp;nbsp; :ColToCheck == [Any of these values] , then 1, else 0 )&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 18:59:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195008#M41591</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-04-25T18:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195020#M41592</link>
      <description>&lt;P&gt;Use the Loc() function to check to see if any values are the same in a list when compared.&amp;nbsp; When doing this with a matrix, convert the matrix to a list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;z=[1,2,3,4];
loc(as list(z),2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2019 19:24:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195020#M41592</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-04-25T19:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195025#M41596</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;I'm trying to do something like this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#1 it expects a numeric.&lt;/P&gt;&lt;P&gt;#2 the return is coming back all missing values.&amp;nbsp; I tried data type expression and numeric, couldn't run distribution to see if there were values other than missing value.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cust = ["customer1","customer2","customer3"];

If( Loc( As List( cust ), :Name( "Ship-To Customer" ) ),
	1,
	0
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;//update 4/26/19&lt;BR /&gt;the orignal post did not have cust defined, instead it showed&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;z = ["customer1","customer2","customer3"];&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;That's why TXNelson is asking what is "cust"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:37:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195025#M41596</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-04-26T14:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195026#M41597</link>
      <description>&lt;P&gt;1. A matrix can only contain numeric values.&amp;nbsp; Therefore, the matrix z needs to be specified as a List, not as a Matrix&lt;/P&gt;
&lt;P&gt;2. I do not know what "cust" is.&lt;/P&gt;
&lt;P&gt;3. Is this a column formula, or open JSL code?&lt;/P&gt;
&lt;P&gt;4. Loc returns a matrix of the positions where the testing value is found in the List.&amp;nbsp; Therefore, you need to determine if more than 0 rows were returned to determine if a match has been found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below are a couple of script examples that might help you out&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

// As a formula in a new column
dt &amp;lt;&amp;lt; New Column( "is present",
	formula(
		z = {"customer1", "customer2", "customer3"};
		If( N Rows( Loc( z, :Name( "Ship-To Customer" ) ) &amp;gt; 0 ),
			1,
			0
		);
	)
);

// In open JSL
z = {"customer1", "customer2", "customer3"};
For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	If( N Rows( Loc( z, :Name( "Ship-To Customer" )[i] ) ) &amp;gt; 0,
		1,
		0
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2019 21:02:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195026#M41597</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-04-25T21:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195049#M41598</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt &amp;lt;&amp;lt; new Column("Some Check", FOrmula(
	//only doing !! so it's negates the output of contains (which is WHERE it is in the list)
	!!Contains({59, 63, 48, 70}, :height)
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Apr 2019 23:01:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195049#M41598</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-04-25T23:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195141#M41602</link>
      <description>&lt;P&gt;Thank you both.&amp;nbsp; &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;TX got me over the hump last night.&amp;nbsp; I just converted characters to numeric and it gave the desired result.&lt;BR /&gt;&lt;BR /&gt;I think&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2610"&gt;@vince_faller&lt;/a&gt;&amp;nbsp;'s solution is what I'm looking for. I tried it with characters and it worked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	New Column( "Some Check 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),&lt;BR /&gt;                Formula( !!Contains( {"TIM", "ALICE", "JANE", "UDY"}, :name ) )
	),&lt;BR /&gt;		//  "UDY" is in there to verify contains will not return true for "JUDY"&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:35:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195141#M41602</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-04-26T14:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: If row column value equals any values of any array then... What is the general form of this formal?</title>
      <link>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195143#M41603</link>
      <description>&lt;P&gt;Not directly.......that is why I use Loc().&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 14:14:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/If-row-column-value-equals-any-values-of-any-array-then-What-is/m-p/195143#M41603</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-04-26T14:14:10Z</dc:date>
    </item>
  </channel>
</rss>

