Publication date: 07/08/2024

Get Column Names

The Column Name(n) message returns the name of the n th column.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column Name( 2 );

age

The returned value is a name value, not a quoted string. What this means is you can use it anywhere you would normally use the actual name in a script. For example, you could subscript it:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column Name( 2 )[1];

12

If you want the name as a text string, quote it with Char:

Char( Column Name( 2 ) );

"age"

To retrieve a list of the column names in a data table, submit Get Column Names.

dt << Get Column Names( argument );

where the optional argument controls the output of the Get Column Names message, as follows:

Specify Numeric, Character, or RowState to include only those column data types.

Specify Continuous, Ordinal, or Nominal to include only those modeling types.

To get all columns names, specify no data type or modeling type.

Specify String to return a list of strings rather than column names. For example, if you want to get numeric and continuous columns in the Big Class.jmp sample data table, proceed as follows:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
names = dt << Get Column Names(Numeric, "Continuous")

{height, weight}

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