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


In the following examples, the name column is unhidden, unexcluded, labeled, and locked from horizontal scrolling.
注意:All the messages to set various arguments (for example, Set Name, Set Values, Set Formula) start with Set. The word Set is optional for all messages except Set Name (recall that Name is already used for something else, the command that lets you use unusual characters in a name). Use whichever form you prefer or find easier to remember. The corresponding messages to retrieve the current value of an argument (for example, Get Formula) are the same, except that they start with Get instead of Set, and the word Get is not optional.
To deselect all selected columns, send a Clear Column Selection message to the data table object.
Set Name lets you name or rename a column, and Get Name returns the name for a column. The following example changes the name of the second column from age to ratio. It then returns the current column name to the log.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = Column( 2 );
col << Set Name( "ratio" );
col << Get Name;
Similarly, Set Values sets values for a column. If the variable is character, the argument should be a list. If the variable is numeric, the argument should be a matrix (vector). If the number of values is greater than the current number of rows, the necessary rows are added to the data table. Get Values returns the values in list or matrix form. Get As Matrix is similar to Get Values but returns values in the numeric columns.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column( "name" ) << Values( {Fred, Wilma, Fred, Ethel, Fred, Lamont} );
Column( "age" ) << Values( [28, 27, 51, 48, 60, 30] );
You can specify value labels in any one of the following three ways. Using the Big Class.jmp sample data table, assume that M maps to Male, and F maps to Female.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
:sex << Value Labels( {"F", "M"}, {"Female", "Male"} ); // use two lists
:sex << Value Labels( {"F", "Female", "M", "Male"} ); // use a list of pairs
:sex << Value Labels( {"F" = "Female", "M" = "Male"} ); // use a list of assignments
You can activate value labels by sending Use Value Labels as a message to the column.
:sex << Use Value Labels( 1 );
:sex << Use Value Labels( 0 );
dt << Use Value Labels( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "New" );
Column( "New" ) << Data Type( Character );
Column( "New" ) << Get Data Type;
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( "New" );
col << Modeling Type( "Continuous" );
col << Get Modeling Type;
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( "Date" );
Column( "Date" ) << Data Type( Numeric, Format( "ddMonYYYY" ) );
The Format message controls numeric and date/time formatting. The first argument is a quoted string from the list of format choices shown in the Column Info window. Subsequent arguments depend on the format choice. You can also set the field width by itself.
For date formats, the Format message sets how dates appear in a data table column. To set the format that you use for entering data, or for displaying the current cell when you have it selected for entry or editing, use the Input Format message.
注意:Do not confuse the Format message for columns with the Format function for converting numeric values to strings according to the format specified (typically used for date/time notation as described in “Date-Time Functions and Formats” on page 134 in the “Types of Data” chapter). Sending a message to an object has a very different effect from using a function that might happen to have the same name.
"Custom",
Substr( "00", 1, 2 - Length( Char( value ) ) ) || Char( value )
12 // number of decimals
Substr( "00", 1, 2) specifies the string, begins the count with the first digit, and ends the count with the second digit.
- Length( Char( value ) ) ) subtracts the length of the string. Alternatively, || Char( value ) subtracts a string representation of the value.
Format( "Precision", 12, 3 ); // 12 pixels wide with 3 significant digits
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( "Ratio" ); // create column and stores its reference
col << Set Formula( :height/:weight ); // set the formula
col << Eval Formula; // evaluate the formula
col << Get Formula; // return the expression :height/:weight
注意: 
To force a single column to evaluate, you can send an Eval Formula command to the column. You can do this inside the command to create the column, right after the Formula clause:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Ratio",
where Formula() is an alias for Set Formula().
However, it is best to wait until you are finished adding a set of formulas, and then use the command Run Formulas to evaluate all of the formulas in their proper order, as follows:
The Run Formulas command is preferable to the Eval Formula command, because while it is evaluating the formulas, Eval Formula does not suppress the background task from evaluating them again. The formula dependency system background task takes great care to evaluate the formulas in the right order, and RunFormulas simply calls this task until all the formulas are finished evaluating.
If you use random numbers and use the Random Reset(seed) feature to make a reproducible sequence, then you have another reason to use Run Formulas, in order to avoid a second evaluation in the background.
If formula suppression is enabled with Supress Eval, turn it off to enable Eval Formula to run.
The Add Custom Function() function enables you to create your own functions and display them in the Formula Editor’s Functions list. See Create Custom Functions, Transforms, and Formats for details.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column( "sex" ) << List Check( {"M", "F"} ); // set the property
Column( "sex" ) << List Check(); // clear the property
a x b
a x <b
a < x b
a < x < b
Column( "age" ) << Range Check( LTLT( 0, 120 ) );
All of the functions can be preceded by Not and one of them can be missing. The following example specifies that the values in the age column should be greater than or equal to 12:
Column( "age" ) << Range Check( not( LT( 12 ) ) );
Column( "age" ) << Range Check();
To retrieve the list or range check assigned to a column, send a Get List Check or Get Range Check message to the column:
Column( "sex" ) << Get List Check;
Column( "age" ) << Get Range Check;
Here is an example of Get Range Check for the age column in Big Class.jmp:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column( "age" ) << Range Check( LTLT( 0, 120 ) );
Column( "age" ) << Get Range Check;
Note that you can also use Set Property, Get Property, and Delete Property to set, retrieve, and remove list checks and range checks. See Column Properties for more information.
Get Script returns a script to create the column.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "Ratio", Set Formula( :height/ :weight) );
Column( "Ratio" ) << Get Script;
To preselect a role on a column, use the Preselect Role message. Choices include No Role, X, Y, Weight, and Freq. The Get Role message returns the current setting.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = New Column( "New" );
col << Preselect Role( X );
col << Get Role;
To lock or unlock a column, use Lock or Set Lock with a Boolean argument. Get Lock returns the current setting.