<?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: Referencing columns from other tables in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281430#M54501</link>
    <description>&lt;P&gt;ah.&amp;nbsp; it looks like all of my columns after column 2 have a (xxx) in the name - the units of the measurement.&amp;nbsp; That could be it?&amp;nbsp; The log is throwing an error for every column like that&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jul 2020 16:46:21 GMT</pubDate>
    <dc:creator>bwkeller2</dc:creator>
    <dc:date>2020-07-23T16:46:21Z</dc:date>
    <item>
      <title>Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281265#M54467</link>
      <description>&lt;P&gt;I'm trying to make a new table by reading from two source tables.&amp;nbsp; I'd like to avoid joining them into one big table and manipulating from there.&amp;nbsp; The new table will be an array of deltas between the two source tables.&amp;nbsp; The script is creating the columns just fine, but it's not populating them with anything.&amp;nbsp; I'm assuming there's some syntax i'm missing in referencing columns from other tables in my formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;predt = Open("C:\...\pre_data.jmp");
predtcols = predt &amp;lt;&amp;lt; Get Column Names (string);
postdt = Open("C:\...\post_data.jmp");
postdtcols = postdt &amp;lt;&amp;lt; Get Column Names (string);
dt = new table ("delta_values");
for (i=1, i &amp;lt;= NCols(predt), i++,
	dt &amp;lt;&amp;lt; New column ("delta_"||predtcols[i], numeric, continuous, formula(postdt:column(postdtcols[i]) - predt:column(predtcols[i])));
	);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:16:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281265#M54467</guid>
      <dc:creator>bwkeller2</dc:creator>
      <dc:date>2023-06-10T23:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281287#M54471</link>
      <description>&lt;P&gt;You had a couple of issues that were byting(pun) you in the butt.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You need to &amp;lt;&amp;lt; Add Rows() to the empty data table;&lt;/LI&gt;
&lt;LI&gt;The format for using the Column() function is not&amp;nbsp; &amp;nbsp; postdt:column( postcols[i] ).&amp;nbsp; If this would be the method to use in this situation, the form would be&amp;nbsp; &amp;nbsp; &amp;nbsp;Column( postdt, postcols[i] ).&amp;nbsp; But that is not what is needed here&lt;/LI&gt;
&lt;LI&gt;Assigning formulas in New Column() operations are a bit tricky.&amp;nbsp; The Formula() that is set is not evaluated before it is made the formula.&amp;nbsp; That is, if you place&amp;nbsp; &amp;nbsp; &amp;nbsp; postcols[i]&amp;nbsp; &amp;nbsp; into a formula, it does not look up the value of postcols[i] as it is building the formula, it just places&amp;nbsp; &amp;nbsp; postcols[i]&amp;nbsp; &amp;nbsp;into the formula, and then attempts to execute it when the formula is run.&amp;nbsp; The issue with this, is that since the variable "i" is being reassigned over and over in a loop, everyone of the formulas that has "i" referenced in it, gets changed every time "i" is changed within JSL.&amp;nbsp; That is not what you want.&amp;nbsp; So what needs to be done, is the evaluate in JSL the exact string of code that you want, and then run that JSL to create the new column.&amp;nbsp; You can see that in the corrected JSL below&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;predt = data table("one");//Open( "C:\...\pre_data.jmp" );
predtcols = predt &amp;lt;&amp;lt; Get Column Names( string );
postdt = data table("two");//Open( "C:\...\post_data.jmp" );
postdtcols = postdt &amp;lt;&amp;lt; Get Column Names( string );
dt = New Table( "delta_values" );
dt &amp;lt;&amp;lt; add rows(nrows(postdt));
For( i = 1, i &amp;lt;= N Cols( predt ), i++,
	Eval(
		Parse(
			"dt &amp;lt;&amp;lt; New Column( \!"delta_" || predtcols[i] || "\!",
		numeric,
		continuous,
		formula( postdt:" ||
			postdtcols[i] || "[Row()] - predt:" || predtcols[i] || "[Row()]) )'"
		)
	)
);
dt &amp;lt;&amp;lt; delete columns("column 1");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Jul 2020 00:59:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281287#M54471</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-23T00:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281371#M54489</link>
      <description>&lt;P&gt;Thanks for the quick response!&amp;nbsp; It looks like i'm only getting the first two columns' deltas with this script.&amp;nbsp; The columns are formatted the same as the rest (numeric, continuous) so i'm not sure what's going on here.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 13:40:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281371#M54489</guid>
      <dc:creator>bwkeller2</dc:creator>
      <dc:date>2020-07-23T13:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281381#M54491</link>
      <description>&lt;P&gt;I assume that it is a data issue.&amp;nbsp; The code worked fine for my test case with 2 columns, but it is written to handle as many columns as it finds in the variable "predt"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= N Cols( predt ), i++,&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So, what you&amp;nbsp; need to do, is to step through the code and check the variable values and see what is happening.&amp;nbsp; Without your data being posted to this discussion, I don't know what is going on.&lt;/P&gt;
&lt;P&gt;Are there any messages being displayed to the Log?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:24:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281381#M54491</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-23T14:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281430#M54501</link>
      <description>&lt;P&gt;ah.&amp;nbsp; it looks like all of my columns after column 2 have a (xxx) in the name - the units of the measurement.&amp;nbsp; That could be it?&amp;nbsp; The log is throwing an error for every column like that&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 16:46:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281430#M54501</guid>
      <dc:creator>bwkeller2</dc:creator>
      <dc:date>2020-07-23T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281431#M54502</link>
      <description>&lt;P&gt;The units (defined as a column property) are not part of the name of the column.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 16:53:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281431#M54502</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-07-23T16:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281719#M54534</link>
      <description>&lt;P&gt;I imported the column names from and excel sheet (output of our tester), so I think they're buried in the column names&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 13:14:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281719#M54534</guid>
      <dc:creator>bwkeller2</dc:creator>
      <dc:date>2020-07-24T13:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Referencing columns from other tables</title>
      <link>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281770#M54548</link>
      <description>That is easy to check.  Double cliick on the column header in JMP and it will open the Col Info window.  It will have the real column name listed.</description>
      <pubDate>Fri, 24 Jul 2020 14:47:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Referencing-columns-from-other-tables/m-p/281770#M54548</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-24T14:47:54Z</dc:date>
    </item>
  </channel>
</rss>

