<?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 copy column from one table to another (bring the formula and the heading in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222103#M44323</link>
    <description>&lt;P&gt;Hi. I have two tables. one with the heading and formula I need.&lt;/P&gt;&lt;P&gt;And at other tables is the one with the formulas. How can copy the column from one table (bring the formula and the heading)&amp;nbsp;to another. Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2019 19:13:04 GMT</pubDate>
    <dc:creator>Batista</dc:creator>
    <dc:date>2019-08-16T19:13:04Z</dc:date>
    <item>
      <title>copy column from one table to another (bring the formula and the heading</title>
      <link>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222103#M44323</link>
      <description>&lt;P&gt;Hi. I have two tables. one with the heading and formula I need.&lt;/P&gt;&lt;P&gt;And at other tables is the one with the formulas. How can copy the column from one table (bring the formula and the heading)&amp;nbsp;to another. Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 19:13:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222103#M44323</guid>
      <dc:creator>Batista</dc:creator>
      <dc:date>2019-08-16T19:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: copy column from one table to another (bring the formula and the heading</title>
      <link>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222164#M44330</link>
      <description>&lt;P&gt;Here is an example of one way to do this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = New Table( "Source",
	add rows( 20 ),
	New Column( "A", formula( Random Integer( 1, 10 ) ) ),
	New Column( "B", formula( Random Integer( 20, 30 ) ) )
);
dt &amp;lt;&amp;lt; run formulas;
dt2 = New Table( "Copy", add rows( 10 ) );

// Create the columns and set the names and formula	
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	dt2 &amp;lt;&amp;lt; New Column( Column( dt, i ) &amp;lt;&amp;lt; get name );
	theFormula = Char( Column( dt, i ) &amp;lt;&amp;lt; get formula );
	Eval(
		Parse(
			"Column( dt2, Column( dt," || Char( i ) || ")&amp;lt;&amp;lt; get name ) &amp;lt;&amp;lt;
					set formula( " || theFormula || ");"
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 17 Aug 2019 10:03:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222164#M44330</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-08-17T10:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: copy column from one table to another (bring the formula and the heading</title>
      <link>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222225#M44342</link>
      <description>Hi thanks! Sorry but I cant understand the script. Would you explain for me in another way?</description>
      <pubDate>Mon, 19 Aug 2019 14:51:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222225#M44342</guid>
      <dc:creator>Batista</dc:creator>
      <dc:date>2019-08-19T14:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: copy column from one table to another (bring the formula and the heading</title>
      <link>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222240#M44347</link>
      <description>&lt;P&gt;If your original post was not talking using a script to do the copying, then what you need to do, is to use&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Tables==&amp;gt;Subset&lt;/P&gt;
&lt;P&gt;Below is a more fully annotated version of the script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// This script creates a couple of example data tables and then runs
// a little script that copies all of the columns from the originating 
// data table to a new data table

// Setup the memory environment
Names Default To Here( 1 );

// Create an example data table that has some formula columns
// The variable "dt" is used as a pointer to this data table
dt = New Table( "Source",
	add rows( 20 ),
	New Column( "A", formula( Random Integer( 1, 10 ) ) ),
	New Column( "B", formula( Random Integer( 20, 30 ) ) )
);
dt &amp;lt;&amp;lt; run formulas;

// Create a new data table that will be used to create the new
// columns in
// Variable "dt2" is used to point to this data table
dt2 = New Table( "Copy", add rows( 10 ) );

// Create the columns and set the names and formula	

// Loop across all columns in the Originating data table
// and retireve the name and formula and then create a new
// column in the new data table
For( i = 1, i &amp;lt;= N Cols( dt ), i++,

	// Create the new column in the new data table, giving it
	// the name from the current data table
	dt2 &amp;lt;&amp;lt; New Column( Column( dt, i ) &amp;lt;&amp;lt; get name );
	// Get the formula from the originating data table
	theFormula = Char( Column( dt, i ) &amp;lt;&amp;lt; get formula );
	
	// Set the formula into the new data table
	Eval(
		Parse(
			"Column( dt2, Column( dt," || Char( i ) || ")&amp;lt;&amp;lt; get name ) &amp;lt;&amp;lt;
					set formula( " || theFormula || ");"
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:19:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/copy-column-from-one-table-to-another-bring-the-formula-and-the/m-p/222240#M44347</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-08-19T16:19:54Z</dc:date>
    </item>
  </channel>
</rss>

