This version of the Help is no longer updated. See JMP.com/help for the latest version.

.
Scripting Guide > Data Tables > Rows > Delete Rows
Publication date: 07/30/2020

Delete Rows

To delete rows, send a Delete Rows message and specify which row or rows to delete. To delete more than one row, give a list or matrix as the rownum argument, or combine Delete Rows with other commands such as For. The rownum argument can be a number, list of numbers, range of numbers, matrix, or an expression that yields one of these. Without an argument, Delete Rows returns the number of selected rows and deletes those rows. When an argument is not specified or rows are not selected, Delete Rows only returns the number of selected rows: 0.

dt << Delete Rows( 10 ); // delete row 10
dt << Delete Rows( {11, 12, 13} ); // delete rows 11-13
myList = {11, 12, 13};
dt << Delete Rows( mylist ); // delete rows 11-13
dt << Delete Rows( 1 :: 20 ); // delete first 20 rows
dt << Delete Rows( [1 2 3] );  // delete first 3 rows

For example, the following script opens Big Class.jmp and deletes row 10:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Selected( Row State( 10 ) ) = 1; // select row 10
dt << Delete Rows;  // delete row 10

You can list duplicate rows, and you can list rows in any order with no consequence.

Here is a general way to remove the bottom x rows of a data table of any size. The following example removes five rows from the bottom of the data table:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
x = 5;
n = N Row( dt );
For( i = n, i > n - x, i--,
	dt << Delete Rows( i )
);

NRow counts the rows in the table. See Iterate a Script on Each Row.

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