You can group columns by sending the data table the Group Columns message, which takes a list of columns to group as an argument. For example, the following code opens the Big Class.jmp sample data table and groups the age and sex columns.
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Group Columns( {:age, :sex} );
"age etc."
You can also send a column name followed by the number of columns to include in the group. The group includes the first column named and the n-1 columns that follow it. This line is equivalent to the line above, which groups age and sex:
dt << Group Columns( :age, 2 );
dt << Group Columns( "My group", :age, 2 );
To ungroup grouped columns, use the Ungroup Columns message, which takes a list of columns in a group as an argument. For example, the following line ungroups the two columns grouped in the previous example.
dt << Ungroup Columns( {:age, :sex} );
You cannot create more than one group in a single message (for example, by giving the Group Columns message two lists of columns). Instead, you must send the data table two separate Group Columns messages.
The Ungroup Columns message takes a list of columns to ungroup, not the name of a group of columns. You can remove a partial list of columns from a group. For example, this line creates a group of four columns:
dt << Group Columns( {:age, :sex, :height, :weight} );
dt << Ungroup Columns( {:age, :sex} );
To get column groups or names, use Get Column Group or Get Column Groups Names. The first part of this example creates two sets of grouped columns as shown in the previous section. Get Column Group() returns the column names in the specific group. Get Column Groups Names() returns the names of the column groups.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Group Columns( {:age, :sex} );
"age etc."
dt << Group Columns( {:weight, :height} );
"height etc."
dt << Get Column Group( "age etc." );
{:age, :sex}
dt << Get Column Group Names();
{"age etc.", "height etc."}
dt << Select Column Group( "name" ); // select the columns in the group
dt << Deselect Column Group( "name" ); // deselect the columns in the group
The following example groups columns X and Y and groups columns Ozone through Lead, and then selects those groups in the data table:
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt << Group Columns( "xy", {:X, :Y} );
dt << Group Columns(
	"pollutants",
	:Ozone :: :Lead
);
dt << Select Column Group( "xy", "pollutants" );
dt << Rename Column Group( "name", "toname" );
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt << Group Columns( "xy", {:X, :Y} );
dt << Group Columns(
	"pollutants",
	:Ozone :: :Lead
);
Wait( 3 );
dt << Rename Column Group( "xy", "coordinates" );
dt << Move Column Group (To First | To Last | After(column) | After(group));
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt << Group Columns( "xy", {:X, :Y} );
dt << Group Columns(
	"pollutants",
	:Ozone :: :Lead
);
dt << Move Column Group( To Last, "pollutants" );

Help created on 7/12/2018