该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


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} );
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} );
dt << Group Columns( {:weight, :height} );
dt << Get Column Group( "age etc." );
dt << Get Column Group Names();
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",
dt << Select Column Group( "xy", "pollutants" );
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt << Group Columns( "xy", {:X, :Y} );
dt << Group Columns(
"pollutants",
Wait( 3 );
dt << Rename Column Group( "xy", "coordinates" );
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt << Group Columns( "xy", {:X, :Y} );
dt << Group Columns(
"pollutants",
dt << Move Column Group( To Last, "pollutants" );