<?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: How to duplicate a column (exact copy except header) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210399#M42129</link>
    <description>Thanks. And If I want to copy the current column which is selected/highlighted?&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 23 May 2019 15:15:06 GMT</pubDate>
    <dc:creator>FN</dc:creator>
    <dc:date>2019-05-23T15:15:06Z</dc:date>
    <item>
      <title>How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/209825#M42070</link>
      <description>&lt;P&gt;I am not sure what is the fastest way to duplicate a column in JMP 14.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Same information (data, metadata, formula) but a different header (column name copy, for example).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 14:31:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/209825#M42070</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2019-05-22T14:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210120#M42075</link>
      <description>&lt;P&gt;From a point-and-click perspective, the shortest way I know is still a 2 step process.&amp;nbsp; You copy/paste the data with a typical Ctrl+C/Ctrl+V operation.&amp;nbsp; You copy/paste the meta data (column properties) by right clicking on a column header of a column you want to duplicate &amp;gt; Copy Column Properties, right click on new copy column &amp;gt; Paste Column Properties.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 16:23:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210120#M42075</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2019-05-22T16:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210127#M42077</link>
      <description>&lt;P&gt;Thanks. Scripting is definitely an option if there is no better way.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 16:28:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210127#M42077</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2019-05-22T16:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210171#M42094</link>
      <description>&lt;P&gt;The easiest thing is to use eval(:col &amp;lt;&amp;lt; Get Script).&amp;nbsp; You will get a copy of the column with an integer at the end to give it a unique name.&amp;nbsp; You would need to make sure the table you want to do the operation on is the current table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a handy function you could use in a script that lets you name the resulting new column and specify the data table.&amp;nbsp; The only required argument is the first one, colname.&amp;nbsp; You can specify a data table, but it will assume Current Data Table() otherwise.&amp;nbsp; If you don't specify a name, it will return the original column name + " - Copy".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

DupCol = function({colname, new = "", dt = Current Data Table() },
	col = Column(dt, colname);
	
	if(IsMissing(new), new = colname||" - Copy");
	
	col_script = char(col &amp;lt;&amp;lt; Get Script);
	col_script = substitute(col_script, "New Column", "dt &amp;lt;&amp;lt; New Column");
	col_script = substitute(col_script, colname, new);
	eval(parse(col_script));
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'll illustrate using the Football sample data (and Big Class to show robustness of the function):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;football_dat = Open("$SAMPLE_DATA/Football.jmp");
DupCol("Height"); //Produces copy of Height named "Height - Copy"
DupCol("Height", new = "Height Again"); //Produces copy of Height named "Height Again"

Open("$SAMPLE_DATA/Big Class.jmp"); //just to show robustness since this data table also has a column named "height"

//Different ways to specify the data table if not wanting to assume Current Data Table
DupCol("Height", new = "Height Once More", dt = Data Table("Football") );
DupCol("Height", new = "Height Last Time", dt = football_dat );&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 18:24:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210171#M42094</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2019-05-22T18:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210399#M42129</link>
      <description>Thanks. And If I want to copy the current column which is selected/highlighted?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 23 May 2019 15:15:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/210399#M42129</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2019-05-23T15:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/379049#M62889</link>
      <description>&lt;P&gt;just an FYI for those using this - i've been using this function periodically, but have had it hang jmp on larger datatables (&amp;gt;100k rows). i haven't thoroughly debugged - but i did find the clone a column thread here (basically the same, except no char() conversion of the script and no substitutions - i'm setting naming using expressions instead) was ~5x faster and i'm hoping won't die in whatever corner cases are causing hang for me.&amp;nbsp; i'm switching my addin to use something based on that, and hoping it is less likely to crash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/clone-a-column/td-p/15644" target="_self"&gt;https://community.jmp.com/t5/Discussions/clone-a-column/td-p/15644&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 16:57:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/379049#M62889</guid>
      <dc:creator>jetpeach</dc:creator>
      <dc:date>2021-04-22T16:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to duplicate a column (exact copy except header)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/379073#M62897</link>
      <description>&lt;P&gt;This snippet of code will return the name of the currently selected column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colName = (current data table() &amp;lt;&amp;lt; get selected columns)[1];&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Apr 2021 18:26:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-duplicate-a-column-exact-copy-except-header/m-p/379073#M62897</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-04-22T18:26:23Z</dc:date>
    </item>
  </channel>
</rss>

