<?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: For Each Row with Insert Into in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933022#M108950</link>
    <description>&lt;P&gt;It is unnecessary to use For Each Row for this (if I understand correctly what you are going for). Just use For Each with &amp;lt;&amp;lt; Get Rows Where and data table subscripting to get the values into your list.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Feb 2026 19:55:29 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-02-27T19:55:29Z</dc:date>
    <item>
      <title>For Each Row with Insert Into</title>
      <link>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933008#M108949</link>
      <description>&lt;P&gt;I'm struggling with an insert into statement inside a For Each Row iteration.&amp;nbsp; I want to look up a category from the column "Type" and based on that select the value in the column "COLUMN_NAME" to form a list for each category.&amp;nbsp; I think I'm failing with the Insert Into&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get the current data table
dt = Current Data Table();

colName = "Type";

// Get the column reference
Types = Column( colName );

// Extract all values from the column
allValues = Types &amp;lt;&amp;lt; Get Values;

// Get unique values (removes duplicates)
Cats = Associative Array( allValues ) &amp;lt;&amp;lt; Get Keys;

// Sort the unique values (optional)
Cats = Sort List( Cats );

// Display results in the log
Show( Cats );

delCats = {"", "-"};
 

For( i = 1, i &amp;lt;= N Items( delCats ), i++,

                Remove From( Cats, As List( Loc( Cats, delCats[i] ) ) )

);

 

show(Cats);


For For( i = 1, i &amp;lt;= N Items( Cats ), i++,

Spud = Char(Cats(i));

Spud = {};

For Each Row(
    // Access column values directly by name
    If(:Type = Char(Cats[i]), Insert Into(Spud, :COLUMN_NAME) ;
);

));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 19:18:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933008#M108949</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2026-02-27T19:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: For Each Row with Insert Into</title>
      <link>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933022#M108950</link>
      <description>&lt;P&gt;It is unnecessary to use For Each Row for this (if I understand correctly what you are going for). Just use For Each with &amp;lt;&amp;lt; Get Rows Where and data table subscripting to get the values into your list.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Feb 2026 19:55:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933022#M108950</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-02-27T19:55:29Z</dc:date>
    </item>
    <item>
      <title>Re: For Each Row with Insert Into</title>
      <link>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933088#M108954</link>
      <description>&lt;P&gt;The code provided cannot be run and is difficult to read as it lacks proper spacing.&amp;nbsp;My guess is that it is AI created as it is using weird techniques for JSL (ordering keys of associative array even though they are already sorted and so on).&lt;/P&gt;
&lt;P&gt;Just based on the code provided (and the question) I'm not sure what you are going for. But, you just might be replacing your Spud list each loop which is messing you up.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Feb 2026 06:32:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933088#M108954</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-02-28T06:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: For Each Row with Insert Into</title>
      <link>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933133#M108955</link>
      <description>&lt;P&gt;The consecutive assignments&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spud = Char(Cats(i));
Spud = {};&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are overwriting the first with the second. They are also inside the outer loop, which is why&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;suggests the list is being recreated rather than extended.&lt;/P&gt;
&lt;P&gt;Adding a&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;show( row(), spud, ...etc... );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement several places to get intermediate results in the log can help too. Or&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;write( "\!n x=" || char(x) || " y=" || char(y) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if you want to format it. Or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;write( Eval Insert("\!n x=^x^ y=^y^) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which might be easier to read.&lt;/P&gt;
&lt;P&gt;The JSL editor has a reformat command that can help when the loop indentation gets visually misaligned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Feb 2026 14:46:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Each-Row-with-Insert-Into/m-p/933133#M108955</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2026-02-28T14:46:01Z</dc:date>
    </item>
  </channel>
</rss>

