I have the script below saved in the Cols menu using in add-in and use it all the time, both when writing scripts to recreate what I did visually and to copy columns from one table to another. Select columns in your source table, run this script, select your target data table, open a new script window, paste what was saved to the clipboard and hit run.
Names default to here(1);
ColumnList = Current Data Table() << Get Selected Columns();
ScriptOut = "";
for( i = 1, i <= n items(ColumnList), i++,
ThisScript = Char(Column( Current Data Table(), ColumnList[i] ) << Get Script) || ";";
ThisScript = substitute( ThisScript, ", Set Selected", "" );
ScriptOut = ScriptOut || If( i > 1, "\!N", "" ) || ThisScript;
);
Set clipboard( ScriptOut );
Example code saved to the clipboard:
New Column("Sepal length Lagged", Numeric, "Continuous", Format("Best", 10), Formula(Lag(As Column("Sepal length"), 1)));
New Column("Sepal width Lagged", Numeric, "Continuous", Format("Best", 10), Formula(Lag(As Column("Sepal width"), 1)));
New Column("Petal length Lagged", Numeric, "Continuous", Format("Best", 10), Formula(Lag(As Column("Petal length"), 1)));
New Column("Petal width Lagged", Numeric, "Continuous", Format("Best", 10), Formula(Lag(As Column("Petal width"), 1)));