<?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 JMP &amp;gt; JSL &amp;gt; Get Formula &amp;gt; Extract Parameters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438650#M68732</link>
    <description>&lt;P&gt;Hi JMP Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have generated multiple prediction formulas stored in columns and I need to extract the parameters to evaluate which variables are common across formulas.&lt;/P&gt;
&lt;P&gt;When I call for dt:Column X &amp;lt;&amp;lt; Get formula, the output is &lt;U&gt;not&lt;/U&gt; a string or list that can be used with standard pattern extraction functions (e.g., Words (), Munger ()...).&lt;/P&gt;
&lt;P&gt;Questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Am I using the right function to collect the formula parameters by using &amp;lt;&amp;lt; Get Formula?&lt;/LI&gt;
&lt;LI&gt;If not, what would be a more appropriate function?&lt;/LI&gt;
&lt;LI&gt;If yes, is there a trick to convert the &amp;lt;&amp;lt; Get formula output to a string, list, or matrix?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 18:05:51 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2023-06-09T18:05:51Z</dc:date>
    <item>
      <title>JMP &gt; JSL &gt; Get Formula &gt; Extract Parameters</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438650#M68732</link>
      <description>&lt;P&gt;Hi JMP Community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have generated multiple prediction formulas stored in columns and I need to extract the parameters to evaluate which variables are common across formulas.&lt;/P&gt;
&lt;P&gt;When I call for dt:Column X &amp;lt;&amp;lt; Get formula, the output is &lt;U&gt;not&lt;/U&gt; a string or list that can be used with standard pattern extraction functions (e.g., Words (), Munger ()...).&lt;/P&gt;
&lt;P&gt;Questions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Am I using the right function to collect the formula parameters by using &amp;lt;&amp;lt; Get Formula?&lt;/LI&gt;
&lt;LI&gt;If not, what would be a more appropriate function?&lt;/LI&gt;
&lt;LI&gt;If yes, is there a trick to convert the &amp;lt;&amp;lt; Get formula output to a string, list, or matrix?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:05:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438650#M68732</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2023-06-09T18:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: JMP &gt; JSL &gt; Get Formula &gt; Extract Parameters</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438669#M68733</link>
      <description>&lt;P&gt;Being pretty "Old School", I handle it by retrieving the formula as a character string&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
x = Char( dt:predicted height &amp;lt;&amp;lt; get formula );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Nov 2021 02:05:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438669#M68733</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-11-21T02:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: JMP &gt; JSL &gt; Get Formula &gt; Extract Parameters</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438670#M68734</link>
      <description>&lt;P&gt;If the interest is in the variable names inside the formula, it might be easier to work directly with the formula expression. Here is an example which extracts unique symbol names out of a formula.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = open("$sample_data/Reliability/Locomotive.jmp");
ex = column(dt, 3)&amp;lt;&amp;lt;getformula;

get_vars = function({ex},{parse_expr, elems},
	elems = {};
	parse_expr = function({ex},{i,exi},
		for (i=1,i&amp;lt;=narg(ex),i++,
			exi = arg(ex,i);
			if (narg(exi)==0,
				if (isname(nameexpr(exi)),
					insert into(elems, lowercase(char(nameexpr(exi))));
				)
				,
				parse_expr(arg(ex,i));
			)
		)
	);

	parse_expr(nameexpr(ex));
	aa = Associative Array( elems );
	aa &amp;lt;&amp;lt; get keys
);

show(get_vars(nameexpr(ex)));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Nov 2021 02:24:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438670#M68734</guid>
      <dc:creator>peng_liu</dc:creator>
      <dc:date>2021-11-21T02:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: JMP &gt; JSL &gt; Get Formula &gt; Extract Parameters</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438671#M68735</link>
      <description>&lt;P&gt;Hi txnelson,&lt;/P&gt;
&lt;P&gt;That was simple.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Sun, 21 Nov 2021 02:30:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/438671#M68735</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-11-21T02:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: JMP &gt; JSL &gt; Get Formula &gt; Extract Parameters</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/541580#M76163</link>
      <description>&lt;P&gt;I'm going to document another approach to this here. &amp;nbsp;(Thanks to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4386"&gt;@Byron_JMP&lt;/a&gt;&amp;nbsp;for the Arg() tutorial on this)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can go through an Arg() command to get the parameters as a list that you can work with pretty easily. &amp;nbsp;I've also put a function below that returns the parameters for a &amp;nbsp;column formula as an Associative Array. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// For a given column, col, in a data table, dt, you can get the formula column property with a message:

formula = dt:Col &amp;lt;&amp;lt; Get Formula;

// the first argument of which is the parameters list which can be extracted using Arg()

params = Arg(formula, 1);

// from there you can index down to get the parameter / value pair

parameterName1 = Arg(params[1],1);
parameterValue1 = Arg(params[1],2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the Function that returns the formula parameters as an associative array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// This function expects a column reference

formulaParameters = Function( {colref},
	{default local}, 
	
	plist = Arg( colref &amp;lt;&amp;lt; Get Formula, 1 );
	
	keys = {};
	values = {};
	For Each( {value, index}, plist,
		Insert Into( keys, Arg( value, 1 ) );
		Insert Into( values, Arg( value, 2 ) );
	);

	parameters = Associative Array( keys, values );	
	
);

// Usage example: 
dt = Current Data Table();
columnWithParameters = dt:Col1 &amp;lt;&amp;lt; Get Column Reference();

parameterAArray = formulaParameters( columnWithParameters );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2022 16:24:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-gt-JSL-gt-Get-Formula-gt-Extract-Parameters/m-p/541580#M76163</guid>
      <dc:creator>MikeD_Anderson</dc:creator>
      <dc:date>2022-09-07T16:24:58Z</dc:date>
    </item>
  </channel>
</rss>

