<?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: Add values from another data table file to current data table file in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412791#M66236</link>
    <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colList = dt &amp;lt;&amp;lt; get column names;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to get the names of the columns in the data table&lt;/P&gt;
&lt;P&gt;and then use a For() loop&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i=1,i&amp;lt;=N Items(colList), i++,
.......
.......
.......
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to perform the operations you need to do for each column.&lt;/P&gt;
&lt;P&gt;These are documented in the Scripting guide and Scripting Index......with examples&lt;/P&gt;</description>
    <pubDate>Thu, 26 Aug 2021 13:44:55 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-08-26T13:44:55Z</dc:date>
    <item>
      <title>Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412679#M66227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hi, I have a doubt regarding JSL script (very new to this!)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've two data files- Table A and Table B.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table A:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_0-1629929355355.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35320i3B2C0EABE96D44C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1629929355355.png" alt="Jacksmith12_0-1629929355355.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table B:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_1-1629929392365.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/35321i4A553EBBB9157326/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_1-1629929392365.png" alt="Jacksmith12_1-1629929392365.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to add values from &lt;STRONG&gt;Table B Column name "Offset"&lt;/STRONG&gt; to &lt;STRONG&gt;each Rows of Column Group "Tests" in Table A&lt;/STRONG&gt;&amp;nbsp;and generate a new data table file with values added.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;P.S.- There are more than 100 columns in the Table A file. How can I use a for loop to iterate all rows and columns?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's what I've tried to start with. Any ideas on this or a more efficient&amp;nbsp;way to do it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;Names Default To Here( 1 );
dt = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );

For Each Row(
	dt:Current = dt:Current + dtOffset:Offset[1];
	dt:Voltage = dt:Voltage + dtOffset:Offset[2];
	dt:Resistance = dt:Resistance + dtOffset:Offset[3];
	dt:Inductance = dt:Inductance + dtOffset:Offset[4];
	dt:Capacitance = dt:Capacitance + dtOffset:Offset[5];
	dt:Power = dt:Power + dtOffset:Offset[6];
	dt:Temperature = dt:Temperature + dtOffset:Offset[7];
	dt:Humidity = dt:Humidity + dtOffset:Offset[8];
	dt:Pressure = dt:Pressure + dtOffset:Offset[9];
	dt:Suseptance = dt:Suseptance + dtOffset:Offset[10];
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6657"&gt;@ih&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:55:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412679#M66227</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T19:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412694#M66228</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Please take the time to read the Scripting Guide and to familiarize yourself with the Scripting Index.&lt;/LI&gt;
&lt;LI&gt;If you need to brush up on general programming skills, there are a large number of sites on the internet that can assist with that.&lt;/LI&gt;
&lt;LI&gt;Here is the simple script that will do what you want
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );

For Each Row(
	dt:Current = dt:Current + dtOffset:Offset[1];
	dt:Voltage = dt:Voltage + dtOffset:Offset[2];
	dt:Resistance = dt:Resistance + dtOffset:Offset[3];
	dt:Inductance = dt:Inductance + dtOffset:Offset[4];
	dt:Capacitance = dt:Capacitance + dtOffset:Offset[5];
	dt:Power = dt:Power + dtOffset:Offset[6];
	dt:Temperature = dt:Temperature + dtOffset:Offset[7];
	dt:Humidity = dt:Humidity + dtOffset:Offset[8];
	dt:Pressure = dt:Pressure + dtOffset:Offset[9];
	dt:Suseptance = dt:Suseptance + dtOffset:Offset[10];
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 26 Aug 2021 01:48:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412694#M66228</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-26T01:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412777#M66233</link>
      <description>&lt;P&gt;Many Thanks&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;you are genius :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 12:54:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412777#M66233</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-26T12:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412778#M66234</link>
      <description>&lt;P&gt;How can I use a loop to perform addition. There are more than 100 columns in Table A?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 12:56:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412778#M66234</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-26T12:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412791#M66236</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colList = dt &amp;lt;&amp;lt; get column names;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to get the names of the columns in the data table&lt;/P&gt;
&lt;P&gt;and then use a For() loop&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(i=1,i&amp;lt;=N Items(colList), i++,
.......
.......
.......
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to perform the operations you need to do for each column.&lt;/P&gt;
&lt;P&gt;These are documented in the Scripting guide and Scripting Index......with examples&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 13:44:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/412791#M66236</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-26T13:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413002#M66275</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I tried. Im not sure what's wrong. Can you please take a look?&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 = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );

colList = dt &amp;lt;&amp;lt; get column names;

For(i=1; N Rows(dt); i++,

	Column(dtOffset)[i] = dt:colList[i] + dtOffset:Offset[i];
	
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Aug 2021 18:20:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413002#M66275</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-26T18:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413028#M66276</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6657"&gt;@ih&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to add values from&amp;nbsp;&lt;STRONG&gt;Table B Column name "Offset"&lt;/STRONG&gt;&amp;nbsp;to&amp;nbsp;&lt;STRONG&gt;each Rows of Column Group "Tests" in Table A&lt;/STRONG&gt;&amp;nbsp;and generate a new data table file with values added. There are more than 100 columns in Table A. How can I use a loop syntax to iterate to each rows and columns?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's what I've tried to start with&lt;/SPAN&gt;&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 = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );

colList = dt &amp;lt;&amp;lt; get column names;

For(i=1; N Rows(dt); i++,

	Column(dtOffset)[i] = dt:colList[i] + dtOffset:Offset[i];
	
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Appreciate if you could suggested&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 20:23:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413028#M66276</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-26T20:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413029#M66277</link>
      <description>&lt;P&gt;The log file entry from when your code is run is:&lt;/P&gt;
&lt;PRE&gt;not enough arguments in access or evaluation of 'For' , For/*###*/(i = 1 ; N Rows( dt ) ; i++, Column( dtOffset )[i] = dt:colList[i]
+dtOffset:Offset[i])

at line 7 in Script 5.jsl&lt;/PRE&gt;
&lt;P&gt;What this is telling you, is that the For() function syntax that you are using is incorrect.&lt;/P&gt;
&lt;P&gt;The correct definition can be found in the Scripting Index, or in the Scripting Guide.&amp;nbsp; Also, if you look at your implementation of the For() function, and the sample I provided, your version is not the same.&lt;/P&gt;
&lt;P&gt;Your solution is going to require that you loop across the columns in your Table A.&amp;nbsp; For each column you will need to get the Offset value that needs to be applied to the values in the Table A column, and then loop through all of the rows in that column, applying the correct offset.&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&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 = Data Table( "Table A" );
dtOffset = Data Table( "Table B" );

colList = dt &amp;lt;&amp;lt; get column names(string);

For( i = 1, i &amp;lt;= N Items( colList ), i++, 
	// Find the offset value in the dtOffset(Table B) data table
	// Because the column name from Table A may not have an offset
	// in Table B that has to be accounted for
	theRow = dtOffset &amp;lt;&amp;lt; get rows where( dtOffset:Tests == colList[i] );
	show(i,nrows(therow));
	// If no rows are returned, no offset was found
	If( N Rows( theRow ) == 1,
		offset = dtOffset:Offset[theRow[1]];
		For( k = 1, k &amp;lt;= N Rows( dt ), k++,
			Column( dt, i )[k] = Column( dt, i )[k] + offset
		);
	);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 20:30:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413029#M66277</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-26T20:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413030#M66278</link>
      <description>&lt;P&gt;The Community Discussion Forum is not a place to go to to have JMP scripts written for you!&amp;nbsp; You need to take the time to learn JSL, and to use the Discussion Forum to help you with specific issues you are not understanding.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 20:36:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413030#M66278</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-08-26T20:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Add values from another data table file to current data table file</title>
      <link>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413205#M66290</link>
      <description>&lt;P&gt;Well, its not just me. I have seen similar posts before&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 14:58:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-values-from-another-data-table-file-to-current-data-table/m-p/413205#M66290</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2021-08-27T14:58:51Z</dc:date>
    </item>
  </channel>
</rss>

