<?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 JSL Script using loops and summary in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308458#M56278</link>
    <description>&lt;P&gt;Need any suggestion on how to make this loop work: itt keeps hiccuping at the line with&amp;nbsp;Group( Box(i) ) and i thought it was an issue with number or brackets / incorrect column names. but adjust these did not help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( j = 1, j &amp;lt; 3, j++, 
    nrj j = dt1 &amp;lt;&amp;lt; Summary(
        Group( Box( i ) ),
        Freq( "None" ),
        Weight( "None" ),
        Link to original data table( 0 ),
        output table name( "Sum " || Char( j ) )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 23:38:03 GMT</pubDate>
    <dc:creator>ClaireR</dc:creator>
    <dc:date>2023-06-09T23:38:03Z</dc:date>
    <item>
      <title>JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308458#M56278</link>
      <description>&lt;P&gt;Need any suggestion on how to make this loop work: itt keeps hiccuping at the line with&amp;nbsp;Group( Box(i) ) and i thought it was an issue with number or brackets / incorrect column names. but adjust these did not help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( j = 1, j &amp;lt; 3, j++, 
    nrj j = dt1 &amp;lt;&amp;lt; Summary(
        Group( Box( i ) ),
        Freq( "None" ),
        Weight( "None" ),
        Link to original data table( 0 ),
        output table name( "Sum " || Char( j ) )
    )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:38:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308458#M56278</guid>
      <dc:creator>ClaireR</dc:creator>
      <dc:date>2023-06-09T23:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308496#M56280</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// I am assuming that your syntax of
//    nrj j = dt1 &amp;lt;&amp;lt; Summary(
// was an attempt to create a pointer to each new data table
// being created in the Loop, one for each column in the list
// of columns called "Box"
// To do that, one needs to create a new List variable, and then
// populate the list by inserting the new data table reference
// by using an "Insert Into()" on each loop

// Create a list variable to hold the data table references
mrj = {};

For( j = 1, j &amp;lt; 3, j++, 

	newDT = dt1 &amp;lt;&amp;lt; Summary(
		// Your reference to the list variable called "Box"
		//      Group( Box(i) ),
		// incorrect for 2 reasons.  1. When referencing a
		// subscript, it is done using square brackets [ ],
		// 2. the index variable you are specifying is "i",
		// while the index variable for your For() loop is
		// a the variable "j"
		Group( Box[j] ),
		Freq( "None" ),
		Weight( "None" ),
		Link to original data table( 0 ),
		output table name( "Sum " || Char( j ) )
	);
	Insert Into( mrj, newDT );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 09:07:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308496#M56280</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-17T09:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308630#M56285</link>
      <description>&lt;P&gt;Thank you Jim.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand the need to add the list variable &amp;amp; the typo. however when i updated the code- &amp;amp; ran it , i get this error. My Column names are "Box 1" . "Box 2" etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However i did try changing the column names to Box1 , Box 2 and Box3 etc , and got the same error. any suggestions?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-09-17_12-10-24.jpg" style="width: 379px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/26821i2D506035FAFD6D41/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2020-09-17_12-10-24.jpg" alt="2020-09-17_12-10-24.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 16:16:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308630#M56285</guid>
      <dc:creator>ClaireR</dc:creator>
      <dc:date>2020-09-17T16:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308695#M56289</link>
      <description>I assumed that Box was referencing a memory variable called Box which is a list, and contains several elements, each one being the name of a variable.  If this isn't it, what is Box?</description>
      <pubDate>Thu, 17 Sep 2020 18:34:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308695#M56289</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-17T18:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308723#M56291</link>
      <description>&lt;P&gt;MMMM i am not sure...my script skills are subpar. Here is my whole code. It runs okay upto the loop section with the summary step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;t1 = Open( "C:\Users\ClaireR\Desktop\Example\ExampleABC.jmp" );

For( i = 1, i &amp;lt;= 5, i++, 

    dt1 &amp;lt;&amp;lt; New Column( "Scenario", Numeric, "Continuous", Formula( :Place ID - i ) );

    dt1 &amp;lt;&amp;lt; New Column( "Box",
        Character,
        "Nominal",
        Formula(
            If( (:Place ID - i) &amp;lt;= 200,
                "Ground",
                If( (:Place ID - i) &amp;lt;= 250,
                    "Drop 1",
                    If( (:Place ID - i) &amp;lt;= 400,
                        "Ground",
                        If( (:Place ID - i) &amp;lt;= 450,
                            "Drop 2",
                            If( (:Place ID - i) &amp;lt;= 600,
                                "Ground",
                                If( (:Place ID - i) &amp;lt;= 650,
                                    "Drop 3",
                                    If( (:Place ID - i) &amp;lt;= 800,
                                        "Ground",
                                        If( (:Place ID - i) &amp;lt;= 850,
                                            "Drop 4",
                                            "Ground"
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )

    );

    dt1 &amp;lt;&amp;lt; New Column( "ActualLoc",
        Character,
        "Nominal",
        Formula(
            If( (:Place ID - i) &amp;lt;= 200,
                "Ground",
                If( (:Place ID - i) &amp;lt;= 250,
                    :Place ID 2,
                    If( (:Place ID - i) &amp;lt;= 400,
                        "Ground",
                        If( (:Place ID - i) &amp;lt;= 450,
                            :Place ID 2,
                            If( (:Place ID - i) &amp;lt;= 600,
                                "Ground",
                                If( (:Place ID - i) &amp;lt;= 650,
                                    :Place ID 2,
                                    If( (:Place ID - i) &amp;lt;= 800,
                                        "Ground",
                                        If( (:Place ID - i) &amp;lt;= 850,
                                            :Place ID 2,
                                            "Ground"
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )


    );

);

:Scenario &amp;lt;&amp;lt; Set Name( "Scenario 1" );
:Box &amp;lt;&amp;lt; Set Name( "Box 1" );
:ActualLoc &amp;lt;&amp;lt; Set Name( "ActualLoc" );

 

mrj = {};

For( j = 1, j &amp;lt; 3, j++, 

    newDT = dt1 &amp;lt;&amp;lt; Summary(
        Group( Box[j] ),
        Freq( "None" ),
        Weight( "None" ),
        Link to original data table( 0 ),
        output table name( "Sum " || Char( j ) )
    );
    Insert Into( mrj, newDT );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 20:00:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308723#M56291</guid>
      <dc:creator>ClaireR</dc:creator>
      <dc:date>2020-09-17T20:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script using loops and summary</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308746#M56293</link>
      <description>&lt;P&gt;I created a data table with a column called Place ID.&amp;nbsp; I populated it with 100 random values that ranged from 1 to 850.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="place1.PNG" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/26831iD96F2DE79D53033F/image-size/large?v=v2&amp;amp;px=999" role="button" title="place1.PNG" alt="place1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I then ran the section of code that various&amp;nbsp; Box and ActualLoc and it created a data table that looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="place2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/26832i75001CDB8FBB63BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="place2.PNG" alt="place2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I do not see the intent with performing these operations.&lt;/P&gt;
&lt;P&gt;It appears to me(I could easily be wrong) that you do not have the understanding of some elements that you are using.&amp;nbsp; Within your first For() loop, you create the same columns of Scenario, Box and ActualLoc 5 times.&amp;nbsp; And since JMP will not allow a column have the same name, when you create Scenario, Box and ActualLoc during the first loop, those are the actual names it will use.&amp;nbsp; However, on loop 2, JMP will force the names to Scenario 2, Box 2 and ActualLoc 2.&amp;nbsp; Loops 3,4,and 5 repeat this behavior.&amp;nbsp; The formulas used are also a little confusing.&amp;nbsp; You are repeatedly using the specification of (:Place ID - i).&amp;nbsp; Since this is being used in a formula, which means that the formula will be applied to each row in the data table, and&amp;nbsp; the result of this calculation will be the value of the variable Place ID for the given row (i.e row 1 in my data table has the value 268) and it will subtract off the current value of i, which has the value of 1 on the first loop, 2 on the second loop, etc.&amp;nbsp; Thus the for row 1, the values range from 267 to 263.&amp;nbsp; I suspect you may be thinking that :Place ID -1 is referencing the column that comes before :Place ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you help me out, and clarify what you are attempting to do to your data table with the column Place ID in it?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 20:52:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-using-loops-and-summary/m-p/308746#M56293</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-09-17T20:52:03Z</dc:date>
    </item>
  </channel>
</rss>

