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


Scripting Guide > Data Tables > Accessing Data Values > Set or Get Values by Column Name
Publication date: 04/30/2021

Set or Get Values by Column Name

The easiest way to refer to a column is by its name. If you have a global variable and a column with the same name, to prevent ambiguity, scope the column name with the : prefix operator.

To set the value of a cell in the current row, provide the column name and the new value.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Row() = 5; // select row 5
dt:age = 19; // set the age in row 5 to 19
dt:name = "Sam"; // set the name in row 5 to Sam

To set the value of a cell in row 10, specify the row number in a subscript.

dt:age[10] = 20; // set the value of age in row 10 to 20

An empty subscript refers to the current row, so :age[ ] is the same as :age.

To get the value of a cell in row 16, specify the column name.

Row() = 16; // select row 16
myGlobal = :age; // store the age as a variable
:age; // returns 14, the age in row 16
Show( :age ); // returns age = 14;

To get the value of a cell in a specific row, include the column name and row number. Both of the following examples return 13, the value of age in row 12 of Big Class.jmp:

:age[12];
myGlobal = :age[12];

To get a value in a data column reference, use Column() and As Column() to get the value in a data column reference. See Access Cell Values through Column References.

Notes:

If you do not specify the row number, the current row is selected.

An empty subscript, such as :age[ ], refers to the current row.

Be careful that you are subscripting to a table row that exists. The default row number is zero, so statements like :name that refer to row zero generate an Invalid Row Number error.

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