<?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: JSL Script to change column name in formula with real formula from the corresponding column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/545374#M76382</link>
    <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/92"&gt;@pauldeen&lt;/a&gt;&amp;nbsp;pointed out you can profile this using expand intermediate formulas, but you can go one step further and use the save expanded formulas formulas option in that profiler to resolve all of those references in a new column formula.&lt;/P&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="ih_0-1663331017226.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45535i377C85BC0C5A5B40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ih_0-1663331017226.png" alt="ih_0-1663331017226.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$Sample_data/iris.jmp" );

dt &amp;lt;&amp;lt; New Column("Log[Petal width]", Numeric, "Continuous", Format("Best", 12), Formula(Log(:Petal width)));
dt &amp;lt;&amp;lt; New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Formula(:Sepal length + :Sepal width + :"Log[Petal width]"n));

prof = Profiler(
	Y( :Column 1 ),
	Profiler(
		1,
		Term Value(
			Sepal length( 6, Lock( 0 ), Show( 1 ) ),
			Sepal width( 3.125, Lock( 0 ), Show( 1 ) ),
			Petal width( 1.269, Lock( 0 ), Show( 1 ) )
		)
	),
	Expand
);

col = prof &amp;lt;&amp;lt; Save Expanded Formulas;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to do this by scripting you have several options.&amp;nbsp; I would start with a for loop that would look for a column reference, check if that column has a formula, and then use the substitute command to insert it.&amp;nbsp; Give it a try and post it here if you get stuck.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 12:33:01 GMT</pubDate>
    <dc:creator>ih</dc:creator>
    <dc:date>2022-09-16T12:33:01Z</dc:date>
    <item>
      <title>JSL Script to change column name in formula with real formula from the corresponding column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/544218#M76311</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to automate the process where I want to change the column name in one formula (i.e. "Lower 90% Indiv TiterHPLCProtA@D14"&amp;nbsp;&amp;nbsp;with the 'real' formula of this column (second picture).&lt;/P&gt;&lt;P&gt;I want to repeat this process for all column names within the first picture.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script would need something like:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Find all column names within the first formula&lt;/LI&gt;&lt;LI&gt;Start with the first column name&lt;/LI&gt;&lt;LI&gt;Find the corresponding column within the data table and copy the formula&lt;/LI&gt;&lt;LI&gt;replace column name in the first formula with the column formula&lt;/LI&gt;&lt;LI&gt;repeat this process until all column names in the first formula have been replaced with their "real" formula&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First column formula&lt;/P&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="Marco__0-1663136180739.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45434i7DEC9F395BD4E579/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Marco__0-1663136180739.png" alt="Marco__0-1663136180739.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;one example of the formula I want to insert in the first column formula, by replacing "[...]TiterHPLCProtA[...]"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Marco__2-1663136425860.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45436i1E2F1DE34E7B1964/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Marco__2-1663136425860.png" alt="Marco__2-1663136425860.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best!&lt;/P&gt;&lt;P&gt;/Marco&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:58:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/544218#M76311</guid>
      <dc:creator>Marco_</dc:creator>
      <dc:date>2023-06-09T15:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script to change column name in formula with real formula from the corresponding column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/544294#M76317</link>
      <description>&lt;P&gt;You can do this with some advanced scripting techniques:&lt;/P&gt;&lt;P&gt;You will have to follow the column name to the column,&lt;/P&gt;&lt;PRE&gt;Formula_expression = Column &amp;lt;&amp;lt; get formula&lt;/PRE&gt;&lt;P&gt;Then you can substitute the column references with the formula expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So look into expr(), name expr(), and substitute into().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the only reason you do this is for the use in Profiler, you can just turn on the check box here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_0-1663146199309.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45437iBF9CE38D841957E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_0-1663146199309.png" alt="pauldeen_0-1663146199309.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 09:04:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/544294#M76317</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2022-09-14T09:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script to change column name in formula with real formula from the corresponding column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/545374#M76382</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/92"&gt;@pauldeen&lt;/a&gt;&amp;nbsp;pointed out you can profile this using expand intermediate formulas, but you can go one step further and use the save expanded formulas formulas option in that profiler to resolve all of those references in a new column formula.&lt;/P&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="ih_0-1663331017226.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45535i377C85BC0C5A5B40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ih_0-1663331017226.png" alt="ih_0-1663331017226.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$Sample_data/iris.jmp" );

dt &amp;lt;&amp;lt; New Column("Log[Petal width]", Numeric, "Continuous", Format("Best", 12), Formula(Log(:Petal width)));
dt &amp;lt;&amp;lt; New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Formula(:Sepal length + :Sepal width + :"Log[Petal width]"n));

prof = Profiler(
	Y( :Column 1 ),
	Profiler(
		1,
		Term Value(
			Sepal length( 6, Lock( 0 ), Show( 1 ) ),
			Sepal width( 3.125, Lock( 0 ), Show( 1 ) ),
			Petal width( 1.269, Lock( 0 ), Show( 1 ) )
		)
	),
	Expand
);

col = prof &amp;lt;&amp;lt; Save Expanded Formulas;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to do this by scripting you have several options.&amp;nbsp; I would start with a for loop that would look for a column reference, check if that column has a formula, and then use the substitute command to insert it.&amp;nbsp; Give it a try and post it here if you get stuck.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:33:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/545374#M76382</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2022-09-16T12:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script to change column name in formula with real formula from the corresponding column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/546532#M76426</link>
      <description>&lt;P&gt;Thanks a lot to both of you! That was exactly what I was looking for!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 07:22:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-change-column-name-in-formula-with-real-formula/m-p/546532#M76426</guid>
      <dc:creator>Marco_</dc:creator>
      <dc:date>2022-09-20T07:22:47Z</dc:date>
    </item>
  </channel>
</rss>

