<?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: Set Formula Loop - Using a column string &amp;amp; variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35669#M21038</link>
    <description>&lt;P&gt;That worked beautifully! Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2017 20:06:29 GMT</pubDate>
    <dc:creator>ngodfrey</dc:creator>
    <dc:date>2017-02-10T20:06:29Z</dc:date>
    <item>
      <title>Set Formula Loop - Using a column string &amp; variable</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35665#M21036</link>
      <description>&lt;P&gt;I have two variables that are used to define 15 columns total. They are a = {"1", "2", "3", "4", "5"} and b = {"1", "2", "3"}. Currently there are 15 columns that are already created with the notation of Column("11"), Column("12"), Column("13"), Column("21"), aka Column(b[1] || a[1]), Column(b[1] || a[2]), etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I averaged the first 6 rows of those 15 existing columns and placed it into an array of size 15. I called this array "ave".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So ave[1] would be the average of the first 6 rows in Column("11"), ave[2] would be the average of the first 6 rows in Column("12"), etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, what I would like to do is create 15 new columns prefixed with&amp;nbsp;"D"&amp;nbsp;using both 'a' &amp;amp; 'b' arrays. Also, have a formula set for those columns that takes the existing column - the average 6 rows of that column.&lt;/P&gt;&lt;P&gt;For example, the formula for Column("D11") would be the following:&lt;/P&gt;&lt;P&gt;:Name("11") - ave[1]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column("D12") would be the following:&lt;/P&gt;&lt;P&gt;:Name("12") - ave[2]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;index = 1;&lt;BR /&gt;For( i = 3, i &amp;gt; 0, i--,
	For( j = 5, j &amp;gt; 0, j--,
		at &amp;lt;&amp;lt; Add Multiple Columns( "D" || b[i] || a[j], 1, numeric, continuous, );
		
		F = Eval Expr(expr(ave[index]));
		
		Column( "D" || b[i] || a[j] ) &amp;lt;&amp;lt; Set Formula( :Name("11")-Name Expr(F) );
		index = index + 1;
		
	);
);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code above does not work when I attempt to increment the index variable through the 15 averaged values stored in "ave". The other problem is I need to iterate through :Name("11"), :Name("12"), etc. through all combinations of a &amp;amp; b in the formula. I almost need a way to set the formula in the following manner:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;:Name(b[i] || a[i])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, :Name must use a string with quotes between them and won't let you do it that way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried multiple methods with parse, eval, etc. but with no luck.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 18:20:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35665#M21036</guid>
      <dc:creator>ngodfrey</dc:creator>
      <dc:date>2017-02-10T18:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Set Formula Loop - Using a column string &amp; variable</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35668#M21037</link>
      <description>&lt;P&gt;Here is a piece of JSL that will work.&amp;nbsp; It uses a method where the exact character string of what the required command needs to be is generated, and then Eval(Parse()) to run the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
index = 1;
;
For( i = 3, i &amp;gt; 0, i--,
	For( j = 5, j &amp;gt; 0, j--,
		Eval(
			Parse(
				"at &amp;lt;&amp;lt; New Column(\!"D" || b[i] || a[j] ||
				"\!",1,numeric,continuous,Formula( :Name( \!""
				 || Char( index + 10 ) || "\!" ) - " || Char( ave[index] ) || "));"
			)
		);
		index = index + 1;
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Feb 2017 19:32:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35668#M21037</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-02-10T19:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Set Formula Loop - Using a column string &amp; variable</title>
      <link>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35669#M21038</link>
      <description>&lt;P&gt;That worked beautifully! Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 20:06:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Set-Formula-Loop-Using-a-column-string-amp-variable/m-p/35669#M21038</guid>
      <dc:creator>ngodfrey</dc:creator>
      <dc:date>2017-02-10T20:06:29Z</dc:date>
    </item>
  </channel>
</rss>

