Scripting Guide > Data Tables > Columns > Add Several Columns at Once
Publication date: 08/13/2020

Add Several Columns at Once

The Add Multiple Columns message creates several columns at once. Arguments include the column name prefix, the number of columns, where to insert them (Before First, After Last, or After(col)), and the data type (Numeric, Row State, or Character(width)). An additional argument, field width, is optional for a numeric column.

// add two row state columns named "beginning <n>" before the first column

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Multiple Columns( "beginning", 2, Before First, Row State );
 

// add three numeric columns named "middle <n>" after the height column

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Multiple Columns( "middle", 3, After( :height ), Numeric );
 

// add four character columns named "end <n>" after the last column

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Add Multiple Columns( "end", 4, After Last, Character( 4 ) );

The column name is a prefix. If multiple columns with the same name are added, a sequential number is appended to each column name (beginning 1, beginning 2, and so on).

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).
.