<?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 Datatable indexing Problem within a Formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549436#M76588</link>
    <description>&lt;P&gt;I am trying to apply the log10 function to an entire column within a data table.&amp;nbsp; The result will be in a new column with a new name.&amp;nbsp; The new column and name are generated by I get an error in the formula portion.&amp;nbsp; Below are the results of the script and the error message.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jump1.JPG" style="width: 894px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45794i7976E28CA83AFE8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="jump1.JPG" alt="jump1.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jump2.JPG" style="width: 529px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45795iF6F880466F8A028C/image-size/large?v=v2&amp;amp;px=999" role="button" title="jump2.JPG" alt="jump2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = As Table(J(5, 5, Random Uniform()), &amp;lt;&amp;lt;column names({"X1", "X2", "X3", "X4", "X5"}));
ColNames = dt &amp;lt;&amp;lt; Get Column Names(String);

For(i = 1, i &amp;lt;= N Items(ColNames), i++, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get name of column to work &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex2 = (ColNames[i]);

&amp;nbsp;&amp;nbsp;&amp;nbsp; //place prefix on column name
&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex = "Ln_";

&amp;nbsp;&amp;nbsp;&amp;nbsp; //concatenate prefix and column name
&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex3 = ex || (Char(ex2));

&amp;nbsp;&amp;nbsp;&amp;nbsp; //Create new column and put results on log of original column in new column
&amp;nbsp;&amp;nbsp;&amp;nbsp;	dt &amp;lt;&amp;lt; New Column(ex3, "Numeric", formula(Ln(:ex2)));

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Thanks for your help in advance.&lt;/DIV&gt;
&lt;DIV class=""&gt;Ray&lt;/DIV&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:54:44 GMT</pubDate>
    <dc:creator>RayOq</dc:creator>
    <dc:date>2023-06-10T23:54:44Z</dc:date>
    <item>
      <title>Datatable indexing Problem within a Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549436#M76588</link>
      <description>&lt;P&gt;I am trying to apply the log10 function to an entire column within a data table.&amp;nbsp; The result will be in a new column with a new name.&amp;nbsp; The new column and name are generated by I get an error in the formula portion.&amp;nbsp; Below are the results of the script and the error message.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jump1.JPG" style="width: 894px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45794i7976E28CA83AFE8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="jump1.JPG" alt="jump1.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jump2.JPG" style="width: 529px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45795iF6F880466F8A028C/image-size/large?v=v2&amp;amp;px=999" role="button" title="jump2.JPG" alt="jump2.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = As Table(J(5, 5, Random Uniform()), &amp;lt;&amp;lt;column names({"X1", "X2", "X3", "X4", "X5"}));
ColNames = dt &amp;lt;&amp;lt; Get Column Names(String);

For(i = 1, i &amp;lt;= N Items(ColNames), i++, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get name of column to work &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex2 = (ColNames[i]);

&amp;nbsp;&amp;nbsp;&amp;nbsp; //place prefix on column name
&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex = "Ln_";

&amp;nbsp;&amp;nbsp;&amp;nbsp; //concatenate prefix and column name
&amp;nbsp;&amp;nbsp;&amp;nbsp;	ex3 = ex || (Char(ex2));

&amp;nbsp;&amp;nbsp;&amp;nbsp; //Create new column and put results on log of original column in new column
&amp;nbsp;&amp;nbsp;&amp;nbsp;	dt &amp;lt;&amp;lt; New Column(ex3, "Numeric", formula(Ln(:ex2)));

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;Thanks for your help in advance.&lt;/DIV&gt;
&lt;DIV class=""&gt;Ray&lt;/DIV&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:54:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549436#M76588</guid>
      <dc:creator>RayOq</dc:creator>
      <dc:date>2023-06-10T23:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datatable indexing Problem within a Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549697#M76611</link>
      <description>&lt;P&gt;You need to evaluate the column name into the formula. This is a good post about it&amp;nbsp;&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 07:25:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549697#M76611</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-27T07:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Datatable indexing Problem within a Formula</title>
      <link>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549714#M76615</link>
      <description>&lt;P&gt;Here's just the script.&amp;nbsp; But definitely the article is more in depth.&amp;nbsp;&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);
dt = As Table(J(5, 5, Random Uniform()), &amp;lt;&amp;lt;column names({"X1", "X2", "X3", "X4", "X5"}));
ColNames = dt &amp;lt;&amp;lt; Get Column Names(String);

For(i = 1, i &amp;lt;= N Items(ColNames), i++, 
    col_name = ColNames[i];
    Eval(
		EvalExpr(// if you just evaluate this block you'll see that the col_name var has been replaced
			dt &amp;lt;&amp;lt; New Column("Ln_"||col_name, numeric, formula(
				ln(Expr(Column(dt, col_name))[]) 
			));
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Sep 2022 10:46:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Datatable-indexing-Problem-within-a-Formula/m-p/549714#M76615</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2022-09-27T10:46:05Z</dc:date>
    </item>
  </channel>
</rss>

