<?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 Looping through rows of a column to find the overall count in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674007#M86143</link>
    <description>&lt;P&gt;Trying to find the number of counts of current entry in a column. The below function works but seems to be slow. Any suggestions to improve the script run time?&lt;/P&gt;&lt;P&gt;JMP14, JMP16&lt;/P&gt;&lt;P&gt;&amp;lt;For each row(Print(Col Number( :ColName, :ColName )))&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My proposal: I think initially constructing Associative Array by adding the entries from the :ColName as "Key" and increasing the value (Value++) when duplicate entry i.e. duplicate Key or if it's a new entry, adding a separate Key with value set to 1 would be a better way. Then you can just loop through rows to find the number of "Value" for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2023 08:19:21 GMT</pubDate>
    <dc:creator>PredictorRoot52</dc:creator>
    <dc:date>2023-09-04T08:19:21Z</dc:date>
    <item>
      <title>Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674007#M86143</link>
      <description>&lt;P&gt;Trying to find the number of counts of current entry in a column. The below function works but seems to be slow. Any suggestions to improve the script run time?&lt;/P&gt;&lt;P&gt;JMP14, JMP16&lt;/P&gt;&lt;P&gt;&amp;lt;For each row(Print(Col Number( :ColName, :ColName )))&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My proposal: I think initially constructing Associative Array by adding the entries from the :ColName as "Key" and increasing the value (Value++) when duplicate entry i.e. duplicate Key or if it's a new entry, adding a separate Key with value set to 1 would be a better way. Then you can just loop through rows to find the number of "Value" for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 08:19:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674007#M86143</guid>
      <dc:creator>PredictorRoot52</dc:creator>
      <dc:date>2023-09-04T08:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674052#M86146</link>
      <description>&lt;P&gt;Is there a specific reason why you wish to loop over the rows? You could most likely use Tabulate or Summary table to perform similar task&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1693818618022.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56203iB65482C39D254148/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1693818618022.png" alt="jthi_0-1693818618022.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Summary + Stack table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1693818642336.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56204iB14E45496FB0A94C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1693818642336.png" alt="jthi_1-1693818642336.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 09:11:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674052#M86146</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-09-04T09:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674238#M86166</link>
      <description>&lt;P&gt;Here are a couple of ways to do what I believe you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Current Data Table();

Summarize( dt, items = by( :colName ) );
countOfUniqueValues = N Items( items );

// or

countOfUniqueValues = N Items( Associative Array( :colName ) &amp;lt;&amp;lt; get keys );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Sep 2023 20:40:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/674238#M86166</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-04T20:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676597#M86323</link>
      <description>&lt;P&gt;I am summarizing (dt_summary) the bigger data table (dt) which gives me the number of rows for each particular entry in the column: ColName.&lt;/P&gt;&lt;PRE&gt;dt_summary = dt &amp;lt;&amp;lt; Summary( Group( :ColName ), Freq( "None" ), Weight( "None" ) );&lt;/PRE&gt;&lt;P&gt;Now I want to iterate through the original table (dt) rows and get the number of rows from summary table for current row to check if above 10 (occurrences).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Summary Table (group by height):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PredictorRoot52_0-1694465350276.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56480i1D68404996A19335/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PredictorRoot52_0-1694465350276.png" alt="PredictorRoot52_0-1694465350276.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So let's say I am on first row, the height is 59 and occurrences are 2, I want to populate that information in the current data table (dt) in a new column (height_qty).&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:00:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676597#M86323</guid>
      <dc:creator>PredictorRoot52</dc:creator>
      <dc:date>2023-09-11T21:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676603#M86325</link>
      <description>&lt;P&gt;The simplest solution is to simply merge the summary table into the original table using the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables =&amp;gt; Update&lt;/P&gt;
&lt;P&gt;platform&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt =

// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

dt_summary = dt &amp;lt;&amp;lt; Summary( invisible, Group( :height ), Freq( "None" ), Weight( "None" ) );
dt_summary:N Rows &amp;lt;&amp;lt; set name("height_qty");

dt &amp;lt;&amp;lt; Update(
	With( dt_summary ),
	Match Columns( :height = :height )
);

close( dt_summary, nosave );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:38:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676603#M86325</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-11T21:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through rows of a column to find the overall count</title>
      <link>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676608#M86326</link>
      <description>&lt;P&gt;Really appreciate your quick help, Jim. It worked as expected and the run time reduced to ~2 seconds from almost a minute.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 23:37:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Looping-through-rows-of-a-column-to-find-the-overall-count/m-p/676608#M86326</guid>
      <dc:creator>PredictorRoot52</dc:creator>
      <dc:date>2023-09-11T23:37:13Z</dc:date>
    </item>
  </channel>
</rss>

