<?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: Concatenate strings to create variables within a formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Concatenate-strings-to-create-variables-within-a-formula/m-p/266071#M51816</link>
    <description>&lt;P&gt;JMP does not evaluate the statements within a "formula" definition prior to creating the formula.&amp;nbsp; It assumes the formula is as it needs to be.&amp;nbsp; Therefore the formula needs to be syntactically as needed when specified.&amp;nbsp; The code below handles that for your example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

a = "Tag";

UpperLIMIT = a || ".ULIMIT";
LowerLIMIT = a || ".LLIMIT";

Eval(
	Parse(
		"dt &amp;lt;&amp;lt; New Column( \!"" || a || " Range\!", formula( :"
		 || UpperLIMIT || " - :" || LowerLIMIT || " ) )); "
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 May 2020 12:41:11 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-05-12T12:41:11Z</dc:date>
    <item>
      <title>Concatenate strings to create variables within a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenate-strings-to-create-variables-within-a-formula/m-p/266010#M51802</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;beginner JMP user here,&lt;/P&gt;
&lt;P&gt;I would like to create a new column "Tag Range" which has the formula in it "Tag.ULIMIT-Tag.LLIMIT".&lt;/P&gt;
&lt;P&gt;Tag.ULIMIT and Tag.LLIMIT are columns in my data table.&lt;/P&gt;
&lt;P&gt;I can create the column by explicitly defining the column names in the formula as below, but I would like to replace these with the variables "UpperLIMIT" and "LowerLIMIT".&lt;/P&gt;
&lt;P&gt;(ultimately, I would like to run a script that creates this column based on the tag name selected by the user)&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;Names Default To Here( 1 );
a = "Tag";

UpperLIMIT = a || ".ULIMIT";
LowerLIMIT = a || ".LLIMIT";

dt = Current Data Table();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This works:&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( a || " Range", formula( :Tag.ULIMIT - :Tag.LLIMIT ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;this doesn;t work:&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Column( a || " Range", formula( :UpperLIMIT - :LowerLIMIT ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:14:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenate-strings-to-create-variables-within-a-formula/m-p/266010#M51802</guid>
      <dc:creator>spudton</dc:creator>
      <dc:date>2023-06-10T23:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate strings to create variables within a formula</title>
      <link>https://community.jmp.com/t5/Discussions/Concatenate-strings-to-create-variables-within-a-formula/m-p/266071#M51816</link>
      <description>&lt;P&gt;JMP does not evaluate the statements within a "formula" definition prior to creating the formula.&amp;nbsp; It assumes the formula is as it needs to be.&amp;nbsp; Therefore the formula needs to be syntactically as needed when specified.&amp;nbsp; The code below handles that for your example&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

a = "Tag";

UpperLIMIT = a || ".ULIMIT";
LowerLIMIT = a || ".LLIMIT";

Eval(
	Parse(
		"dt &amp;lt;&amp;lt; New Column( \!"" || a || " Range\!", formula( :"
		 || UpperLIMIT || " - :" || LowerLIMIT || " ) )); "
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 May 2020 12:41:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Concatenate-strings-to-create-variables-within-a-formula/m-p/266071#M51816</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-12T12:41:11Z</dc:date>
    </item>
  </channel>
</rss>

