<?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 to automatically extract the column name used by the formula in the JSL code? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268812#M52315</link>
    <description>&lt;P&gt;You would have to traverse the arguments of the expression used for the formula, identify the columns, and store them in a list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see JMP &lt;STRONG&gt;Help&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;JMP Documentation Library&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Scripting Guide&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Chapter 8: Lists and Expressions&lt;/STRONG&gt; &amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="page" title="Page 5497"&gt;
&lt;DIV class="layoutArea"&gt;
&lt;DIV class="column"&gt;
&lt;P&gt;&lt;STRONG&gt;Retrieve a Stored Expression Rather than its Result&lt;/STRONG&gt; section. The concepts and the necessary and supporting functions are fully described and demonstrated.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 25 May 2020 13:05:54 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2020-05-25T13:05:54Z</dc:date>
    <item>
      <title>How to automatically extract the column name used by the formula in the JSL code?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268765#M52307</link>
      <description>&lt;P&gt;How to use JSL to automatically extract from a JSL formula the column names used by the formula, and group them into a combination.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For example, in the image of 1, automatically extract the column name to get a combination of 2.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
dt &amp;lt;&amp;lt; New Column( "text", formula( :K36 &amp;gt;= 71.93 &amp;amp; :XA &amp;gt;= -32.3 &amp;amp; :a1 &amp;gt;= -43.67 &amp;amp; :A56 &amp;lt; 18.9 ) );
dt &amp;lt;&amp;lt; run formulas;
Column( "text" ) &amp;lt;&amp;lt; deleteFormula;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2020-05-25_15-56.png" style="width: 801px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24156iD6F8B2F364050113/image-size/large?v=v2&amp;amp;px=999" role="button" title="2020-05-25_15-56.png" alt="2020-05-25_15-56.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 08:12:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268765#M52307</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2020-05-25T08:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically extract the column name used by the formula in the JSL code?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268812#M52315</link>
      <description>&lt;P&gt;You would have to traverse the arguments of the expression used for the formula, identify the columns, and store them in a list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see JMP &lt;STRONG&gt;Help&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;JMP Documentation Library&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Scripting Guide&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Chapter 8: Lists and Expressions&lt;/STRONG&gt; &amp;gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="page" title="Page 5497"&gt;
&lt;DIV class="layoutArea"&gt;
&lt;DIV class="column"&gt;
&lt;P&gt;&lt;STRONG&gt;Retrieve a Stored Expression Rather than its Result&lt;/STRONG&gt; section. The concepts and the necessary and supporting functions are fully described and demonstrated.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 25 May 2020 13:05:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268812#M52315</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-05-25T13:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically extract the column name used by the formula in the JSL code?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268850#M52329</link>
      <description>&lt;P&gt;probably this script does the Job for you:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// generate a table
dt = New Table( "testdata",
	add rows( 3 ),
	New Column( "K36", Continuous, set values( [70, 80, 90] ) ),
	New Column( "XA", Continuous, set values( [30, 32, 33] ) ),
	New Column( "a1", Continuous, set values( [-50, -40, -30] ) ),
	New Column( "A56", Continuous, set values( [10, 20, 10] ) )
);

// add a formula
dt &amp;lt;&amp;lt; New Column( "f1", formula( :K36 &amp;gt;= 71.93 &amp;amp; :XA &amp;gt;= -32.3 &amp;amp; :a1 &amp;gt;= -43.67 &amp;amp; :A56 &amp;lt; 18.9 ) );
dt &amp;lt;&amp;lt; run formulas;

// get formula, convert to string and split words
formula = dt:f1 &amp;lt;&amp;lt; get formula;
formula_txt_words = Words( Char( Name Expr( formula ) ) );

// search for column names in words and put it into list
columns_lst = {};
For( i = 1, i &amp;lt;= N Arg( formula_txt_words ), i++,
	If( Starts With( formula_txt_words[i], ":" ),
		Insert Into( columns_lst, Substitute( formula_txt_words[i], ":", "" ) )
	)
);
Show( columns_lst );

// Group columns
dt &amp;lt;&amp;lt; group columns( "Cols used by f1", columns_lst );
// Column( "text" ) &amp;lt;&amp;lt; deleteFormula;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 May 2020 15:25:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-automatically-extract-the-column-name-used-by-the-formula/m-p/268850#M52329</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2020-05-25T15:25:52Z</dc:date>
    </item>
  </channel>
</rss>

