<?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: Is there any way to quickly get the number of negative values in a column? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78545#M36450</link>
    <description>&lt;P&gt;Jim's answer is great; here are two more that avoid creating a column but have different side effects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );

// using table subscripts, suitable for  use in a column formula.
// As Constant calculates the result once, not for every row.
As Constant( N Rows( Loc( dt[0, "age"] &amp;lt; 15 ) ) ); // 27

// using row selection, suitable for JSL programs. Avoids a temporary
// matrix but does change the selection state of the table.
dt &amp;lt;&amp;lt; selectwhere( age &amp;lt; 15 );
N Rows( dt &amp;lt;&amp;lt; getselectedrows ); // 27
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What you choose depends a bit on whether you'll use it in a column formula or in a JSL program; JMP added the As Constant function (mostly) to support column formulas that need to make an expensive calculation. Without it, JMP would count the number of rows for every row, leading to N^2 performance issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Explaining the first example: dt[0,"age"] returns a matrix from the table (&lt;A href="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013" target="_blank"&gt;post&lt;/A&gt;). 0 means all rows. Comparing that matrix with &amp;lt; 15 returns a matrix of 0 and 1 results. Loc([ 1 0 1 0]) returns a smaller matrix of the locations of the non zero (true) results. NRows or NItems reports the number of elements. As Constant isn't needed in a JSL program if you capture the answer in a variable.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 10:25:08 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2018-10-10T10:25:08Z</dc:date>
    <item>
      <title>Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78537#M36443</link>
      <description>&lt;P&gt;Hello, everyone!&lt;/P&gt;&lt;P&gt;I need to count the number or percentage of negative Numbers on the "Arrival Delay" column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This functionality does not appear to be found in the JMP's menu operations and formulas.&lt;BR /&gt;There is a =countif(,"&amp;lt;0") in excel that can do quickly.&lt;BR /&gt;JMP wants to use a loop?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dt = Open( "$SAMPLE_DATA/Airline Delays.jmp" );&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="2018-10-12_14-21-52.png" style="width: 948px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12742iBC572AED4400989A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-10-12_14-21-52.png" alt="2018-10-12_14-21-52.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 08:00:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78537#M36443</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-10-10T08:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78542#M36447</link>
      <description>&lt;P&gt;Use a Transformation variable with a specified formula of&lt;/P&gt;
&lt;P&gt;If(:Arrival Delay &amp;lt; 0, 1, 0)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use Sum as the statistic in the Summary Platform&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 08:53:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78542#M36447</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-10-10T08:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78543#M36448</link>
      <description>Thank Jim!&lt;BR /&gt;That seems to be the only way.</description>
      <pubDate>Wed, 10 Oct 2018 09:08:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78543#M36448</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-10-10T09:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78545#M36450</link>
      <description>&lt;P&gt;Jim's answer is great; here are two more that avoid creating a column but have different side effects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );

// using table subscripts, suitable for  use in a column formula.
// As Constant calculates the result once, not for every row.
As Constant( N Rows( Loc( dt[0, "age"] &amp;lt; 15 ) ) ); // 27

// using row selection, suitable for JSL programs. Avoids a temporary
// matrix but does change the selection state of the table.
dt &amp;lt;&amp;lt; selectwhere( age &amp;lt; 15 );
N Rows( dt &amp;lt;&amp;lt; getselectedrows ); // 27
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What you choose depends a bit on whether you'll use it in a column formula or in a JSL program; JMP added the As Constant function (mostly) to support column formulas that need to make an expensive calculation. Without it, JMP would count the number of rows for every row, leading to N^2 performance issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Explaining the first example: dt[0,"age"] returns a matrix from the table (&lt;A href="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013" target="_blank"&gt;post&lt;/A&gt;). 0 means all rows. Comparing that matrix with &amp;lt; 15 returns a matrix of 0 and 1 results. Loc([ 1 0 1 0]) returns a smaller matrix of the locations of the non zero (true) results. NRows or NItems reports the number of elements. As Constant isn't needed in a JSL program if you capture the answer in a variable.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 10:25:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78545#M36450</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2018-10-10T10:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78546#M36451</link>
      <description>&lt;BR /&gt;I use it in JSL.&lt;BR /&gt;Please give me specific instructions.&lt;BR /&gt;&lt;BR /&gt;Thank Craige!</description>
      <pubDate>Wed, 10 Oct 2018 10:32:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78546#M36451</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-10-10T10:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there any way to quickly get the number of negative values in a column?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78550#M36454</link>
      <description>dt = Open( "$sample_data/Airline Delays.jmp" );&lt;BR /&gt;&lt;BR /&gt;s=As Constant( N Rows( Loc( dt[0, "Arrival Delay"] &amp;lt; 0 ) ) );Wait(0);&lt;BR /&gt;&lt;BR /&gt;good method!!&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Oct 2018 11:15:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-any-way-to-quickly-get-the-number-of-negative-values-in/m-p/78550#M36454</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-10-10T11:15:39Z</dc:date>
    </item>
  </channel>
</rss>

