For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Data Tables > Work with Columns > Send Messages to Data Column Objects
Publication date: 07/24/2024

Send Messages to Data Column Objects

Just as you send data table messages to a data table reference, you can send column messages to a reference to a data column object. The Column function returns a data column reference. Its argument is either a name in quotation marks, something that evaluates to a name in quotation marks, or a number.

Column( "age" );       // a reference to the age column
col = Column( 2 );     // assign a reference to the second column

Note: You can also use the syntax "Profits ($M)"n to evaluate to a name that contains special characters.

The Scripting Guide uses col to represent data column references. To see the messages that you can send to data column objects, see the Scripting Index (Help > Scripting Index > Objects > Data Tables > Column Scripting). Alternatively, you can use the Show Properties() command:

Show Properties( col );

Note: With column references, you must include a subscript to refer to the individual data values. Without a subscript, the reference is to the column object as a whole.

Once you have stored a data column reference in a global variable, to modify columns, you send messages to the data column reference.

Sending messages to columns is comparable to sending messages to data tables. Either state the object, a double-angle operator <<, and then the message with its arguments in parentheses, or use the Send() function with the object and then the message. In some cases the messages themselves need no arguments, so the trailing parentheses are optional.

col << message( arg, arg2, ... );
Send( col, message(arg, arg2, ... ) );

As with data tables and other types of objects, you can stack or list messages:

col << message << message2 << ...
col << {message, message2, ...};

Tip: To delete a column, you must send the message to a data table reference, because objects cannot delete themselves, only their containers can delete them.

Access Cell Values through Column References

Always use a subscript on a column reference to access the values in the cells of columns. Without a subscript, the reference is to the column object as a whole.

x = col[irow]    // specific row
x = col[]        // current row
col[irow] = 2;   // as an l-value for assignment
dt << Select Where( col[] < 14 );  // in a WHERE clause

Access Cell Values that have Value Labels

If the column whose values you want to access has a Value Label property, you might want to access the value label (formatted value) instead of the actual data value. To do this, use the formatted option. Consider the following example:

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dt << Run Script( "Set Age Value Labels" );
x = Column( dt, "age", formatted )[1];
		Show( x );
y = Column( dt, "age" )[1];
		Show( y );

The log shows the formatted value for x, which is Twelve, and the actual data value for y, which is 12.

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