Stack() combines values from several columns into one column.
dt << Stack(
Columns ( columns ), // the columns to stack together
Source Label Column ( "name" ), // to identify source columns
Stacked Data Column ( "name" ), // name for the new stacked column
Keep ( columns ), // the columns to keep in the data table
Drop ( columns ), // the columns to drop in the data table
Output Table ( "name" ), // name for the new data table
Columns( columns ) ); // specify which columns to include in the stacked table
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
StackedDt = dt << Stack(
Columns( :weight, :height ),
Source Label Column( "ID" ),
Stacked Data Column( "Y" ),
Name( "Non-stacked columns" )( Keep( :age, :sex ) ),
Output Table( "Stacked Table" )
);
The Columns(columns) argument can take a list of columns, or an expression that evaluates to a list.