cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Danial
Level II

How to use 'IF' statements to delete the entire 'Row'?

How to delete the entire 'Row' when the cell is blank/empty ?
3 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to use 'IF' statements to delete the entire 'Row'?

There is no need to use an IF() clause in the deleting of the rows with missing values.

// If checking for a character column
dt << delete rows(dt<<get rows where(:link==""));

// If checking for a numeric column
dt << delete rows(dt<<get rows where(isMissing(:Quantity)));
Jim

View solution in original post

JLX
JLX
Level II

Re: How to use 'IF' statements to delete the entire 'Row'?

YEAH, I agree with @txnelson , if you really wanna do this by using if, you can do like below

Names Default To Here( 1 );
dt = Open( "$sample_data/big class.jmp" );

total_rows = N Row( dt );

For( i = total_rows, i >= 1, i--,
	If( :age[i] == 14,
		dt << delete rows( i );
		wait(0.5) // wait for a while to let you see the delete action
	)
);

View solution in original post

ThuongLe
Level IV

Re: How to use 'IF' statements to delete the entire 'Row'?

or you can do this:

Names Default To Here( 1 );
dt = Open( "$sample_data/big class.jmp" );

dt << Select Where(Is Missing(:column_you_want_to_check));
dt << Delete Rows;
Thuong Le

View solution in original post

5 REPLIES 5
Danial
Level II

Re: How to use 'IF' statements to delete the entire 'Row'?

This is an example of the a data table to my problem Operation Product Link Quantity 1 A ABC 1000 1 A ABC 3000 1 A 1350 1 A 1235
txnelson
Super User

Re: How to use 'IF' statements to delete the entire 'Row'?

There is no need to use an IF() clause in the deleting of the rows with missing values.

// If checking for a character column
dt << delete rows(dt<<get rows where(:link==""));

// If checking for a numeric column
dt << delete rows(dt<<get rows where(isMissing(:Quantity)));
Jim
JLX
JLX
Level II

Re: How to use 'IF' statements to delete the entire 'Row'?

YEAH, I agree with @txnelson , if you really wanna do this by using if, you can do like below

Names Default To Here( 1 );
dt = Open( "$sample_data/big class.jmp" );

total_rows = N Row( dt );

For( i = total_rows, i >= 1, i--,
	If( :age[i] == 14,
		dt << delete rows( i );
		wait(0.5) // wait for a while to let you see the delete action
	)
);
Danial
Level II

Re: How to use 'IF' statements to delete the entire 'Row'?

Thank you so much. Thanks for clearing things up

ThuongLe
Level IV

Re: How to use 'IF' statements to delete the entire 'Row'?

or you can do this:

Names Default To Here( 1 );
dt = Open( "$sample_data/big class.jmp" );

dt << Select Where(Is Missing(:column_you_want_to_check));
dt << Delete Rows;
Thuong Le