The easiest thing is to use eval(:col << Get Script). You will get a copy of the column with an integer at the end to give it a unique name. You would need to make sure the table you want to do the operation on is the current table.
Here's a handy function you could use in a script that lets you name the resulting new column and specify the data table. The only required argument is the first one, colname. You can specify a data table, but it will assume Current Data Table() otherwise. If you don't specify a name, it will return the original column name + " - Copy".
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 << Get Script);
col_script = substitute(col_script, "New Column", "dt << New Column");
col_script = substitute(col_script, colname, new);
eval(parse(col_script));
);
I'll illustrate using the Football sample data (and Big Class to show robustness of the function):
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 );
-- Cameron Willden