<?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: Searching Maximum value of each row across several column and name of source column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557955#M77149</link>
    <description>&lt;P&gt;Here is another way of solving the problem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
dt &amp;lt;&amp;lt; Select Columns( 2 :: 14 );
col = dt &amp;lt;&amp;lt; Get Selected Columns( );

dt &amp;lt;&amp;lt; new column("MaxVal", set each value(Max(col)));
dt &amp;lt;&amp;lt; new column("MaxVal Column", character, set each value(char(col[loc(matrix(col),:MaxVal)[1]])));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 16:24:23 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-10-19T16:24:23Z</dc:date>
    <item>
      <title>Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557893#M77143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm trying to come up with a jsl script which can find max value of each row and the column name corresponding to the max value. I was able to find the max value across all the columns but need some advice to find the column name corresponding to the max value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
dt &amp;lt;&amp;lt; Select Columns( 2 :: 14 );
col = dt &amp;lt;&amp;lt; Get Selected Columns( );
val = dt:MaxVal &amp;lt;&amp;lt; get values( Format( "Best", 12 ) );

dt:Maximum Value &amp;lt;&amp;lt; Set Formula( Max(col) );
nc = (N Items( col ));



For( j = 1, j &amp;lt;= N Items( val ), j++,
	xxx = {};

	For( i = 1, i &amp;lt;= nc, i++,
		If( Contains( char(col[i]), val[j] ),
			Insert Into( xxx, char(col[i]) )
		)
	);
	Column( dt, 16 )[j] =  xxx;
);



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:00:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557893#M77143</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T16:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557926#M77144</link>
      <description>&lt;P&gt;There are many ways of doing this. Below is one example which should get you what you need:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/Sample data.jmp");

col_names = (dt &amp;lt;&amp;lt; Get Column Names("String"))[2::(N Cols() - 2)];

m = dt[0, col_names];

Column(dt, "Maximum Value") &amp;lt;&amp;lt; Set Values(V Max(m`));

Column(dt, "Maximum Col Name") &amp;lt;&amp;lt; Set Data Type("Character");
Column(dt, "Maximum Col Name") &amp;lt;&amp;lt; Set Each Value(
	max_idx = Loc(m[Row(), 0], :Maximum value)[1];
	col_names[max_idx];
);&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;Edit: Copy pasted correct script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit2: Second quite similar option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/Sample data.jmp");
Column(dt, "Maximum Col Name") &amp;lt;&amp;lt; Set Data Type("Character");

col_names = (dt &amp;lt;&amp;lt; Get Column Names("String"))[2::(N Cols() - 2)];

Column(dt, "Maximum Value") &amp;lt;&amp;lt; Set Each Value(Max(dt[Row(), col_names]));
Column(dt, "Maximum Col Name") &amp;lt;&amp;lt; Set Each Value(
	// could use loc max, but as we need maximum value in column, we can just use that with Loc
	max_idx = Loc(dt[Row(), col_names], :Maximum value)[1];
	col_names[max_idx];
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:14:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557926#M77144</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-10-19T16:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557933#M77145</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;Thanks. Your code finds max value across column it seems and I want to evaluate max value of each row across multiple columns. I am expecting the following results&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_0-1666195377045.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46417i04F305A5F6868EFD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1666195377045.png" alt="Jacksmith12_0-1666195377045.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:04:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557933#M77145</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2022-10-19T16:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557945#M77147</link>
      <description>&lt;P&gt;I had copy-pasted some very weird script, I have now edited it to correct one&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:11:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557945#M77147</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-10-19T16:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557955#M77149</link>
      <description>&lt;P&gt;Here is another way of solving the problem&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();
dt &amp;lt;&amp;lt; Select Columns( 2 :: 14 );
col = dt &amp;lt;&amp;lt; Get Selected Columns( );

dt &amp;lt;&amp;lt; new column("MaxVal", set each value(Max(col)));
dt &amp;lt;&amp;lt; new column("MaxVal Column", character, set each value(char(col[loc(matrix(col),:MaxVal)[1]])));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 16:24:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/557955#M77149</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-19T16:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/615700#M81545</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; new column("MaxVal Column", character, set each value(char( col[loc(As List(matrix(col)),:MaxVal)[1] ])));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Propose above correction to last line for JMP14 atleast: the matrix(col) returns a matrix and the loc function needs a list as first argument so the matrix needs to be converted into a list with "As list".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 04:44:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/615700#M81545</guid>
      <dc:creator>OrdinaryParrot2</dc:creator>
      <dc:date>2023-03-23T04:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Maximum value of each row across several column and name of source column</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/769149#M94964</link>
      <description>&lt;P&gt;Thanks for this Jim! Just used this on 250 columns. Hope you are doing well.&lt;BR /&gt;I am now a long way from Texas. &lt;A title="A long, long way from Texas!" href="https://maps.app.goo.gl/EkhhVJUPxdiqgbHq9" target="_blank" rel="noopener"&gt;Map&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 07:21:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-Maximum-value-of-each-row-across-several-column-and/m-p/769149#M94964</guid>
      <dc:creator>markschahl</dc:creator>
      <dc:date>2024-06-28T07:21:11Z</dc:date>
    </item>
  </channel>
</rss>

