<?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: How do I use a variable to reference a column in formula function? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596614#M80025</link>
    <description>&lt;P&gt;Because the formula entry is executed during the running of the column, not during the creation of the column, what is presented in the formula, needs to be the complete JSL required for processing.&lt;/P&gt;
&lt;P&gt;Here is how I handle such issues&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
yCol =":weight";

dt = currentdatatable();
eval(parse("dt&amp;lt;&amp;lt;new column(\!"sum\!", formula(" || yCol || "+:height));"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Feb 2023 23:24:01 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2023-02-02T23:24:01Z</dc:date>
    <item>
      <title>How do I use a variable to reference a column in formula function?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596562#M80022</link>
      <description>&lt;P&gt;Hi, I need to create a new column by apply formula on two existing column. I want to reference column through a variable rather than direct referencing. Here is the code , but formula seems doesn't recognize Column(ColVar). Anyone could help me to fix it? Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;yCol = Column("weight");
xCol = Column("height");
Bivariate( Y( yCol ), X( xCol) );
colVar ="$weight";
dt = currentdatatable();
dt&amp;lt;&amp;lt;new column("sum", formula(column(ColVar)+:height));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:38:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596562#M80022</guid>
      <dc:creator>TraceTurtle5488</dc:creator>
      <dc:date>2023-06-08T16:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a variable to reference a column in formula function?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596614#M80025</link>
      <description>&lt;P&gt;Because the formula entry is executed during the running of the column, not during the creation of the column, what is presented in the formula, needs to be the complete JSL required for processing.&lt;/P&gt;
&lt;P&gt;Here is how I handle such issues&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
yCol =":weight";

dt = currentdatatable();
eval(parse("dt&amp;lt;&amp;lt;new column(\!"sum\!", formula(" || yCol || "+:height));"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2023 23:24:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596614#M80025</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-02-02T23:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a variable to reference a column in formula function?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596788#M80047</link>
      <description>&lt;P&gt;Here is just another example using&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;eval(eval expr( expr ()))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but using the same strategy, implement the value of the variable into the formula.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// get column names and show results
col_lst = dt &amp;lt;&amp;lt; get column names();
my_cols= col_lst[4::5];
show(col_lst, my_cols);

// implement new formula
Eval( Eval Expr( dt &amp;lt;&amp;lt; New Column( "sum of ", formula( sum(Expr(my_cols )) ) ) ) );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 11:59:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-use-a-variable-to-reference-a-column-in-formula/m-p/596788#M80047</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2023-02-03T11:59:58Z</dc:date>
    </item>
  </channel>
</rss>

