<?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: Please help for how to script to select the 4 highest cell value in a column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721409#M90348</link>
    <description>&lt;P&gt;Thanks much to Craige_Hales for a quick response.&lt;/P&gt;&lt;P&gt;It works well&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 19:13:28 GMT</pubDate>
    <dc:creator>VD</dc:creator>
    <dc:date>2024-02-01T19:13:28Z</dc:date>
    <item>
      <title>Please help for how to script to select the 4 highest cell value in a column</title>
      <link>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721081#M90310</link>
      <description />
      <pubDate>Thu, 01 Feb 2024 00:48:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721081#M90310</guid>
      <dc:creator>VD</dc:creator>
      <dc:date>2024-02-01T00:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Please help for how to script to select the 4 highest cell value in a column</title>
      <link>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721113#M90311</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );
nr = N Rows( dt ); // needed below to find the end of the ascending sort list
rowsSortedByWeight = Rank( dt:weight &amp;lt;&amp;lt; getvalues ); // Rank gives the indexes, ascending
heavyRows = rowsSortedByWeight[nr - 3 :: nr]; // four biggest at end
For Each( {r}, heavyRows, // get each row number into r from the heavyRows matrix
	// look in the log for the report...
	Write( Eval Insert( "\!nname=^dt:name[r]^ weight=^dt:weight[r]^" ) ) 
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;name=KIRK weight=134&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;name=LESLIE weight=142&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;name=JACLYN weight=145&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;name=LAWRENCE weight=172&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;edit: this will work better with missing values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );
rowsSortedByWeight = Rank( dt:weight &amp;lt;&amp;lt; getvalues ); // Rank gives the indexes, ascending
nr = N Rows( rowsSortedByWeight ); // should handle missing values
heavyRows = rowsSortedByWeight[nr - 3 :: nr]; // four biggest at end
For Each( {r}, heavyRows, // get each row number into r from the heavyRows matrix
	// look in the log for the report...
	Write( Eval Insert( "\!nname=^dt:name[r]^ weight=^dt:weight[r]^" ) ) 
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Rank() will return a short list, without indexes to missing values, so use the number of rows in the ranked list rather than the number of rows in the data table.&lt;/P&gt;
&lt;P&gt;more edit: And if you mean to select the rows in the table,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; selectrows( heavyRows )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2024 01:43:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721113#M90311</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2024-02-01T01:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Please help for how to script to select the 4 highest cell value in a column</title>
      <link>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721409#M90348</link>
      <description>&lt;P&gt;Thanks much to Craige_Hales for a quick response.&lt;/P&gt;&lt;P&gt;It works well&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 19:13:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Please-help-for-how-to-script-to-select-the-4-highest-cell-value/m-p/721409#M90348</guid>
      <dc:creator>VD</dc:creator>
      <dc:date>2024-02-01T19:13:28Z</dc:date>
    </item>
  </channel>
</rss>

