Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Danial
Level I

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
Highlighted
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

Highlighted
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

Highlighted
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;

View solution in original post

5 REPLIES 5
Highlighted
Danial
Level I

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
Highlighted
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

Highlighted
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

Highlighted
Danial
Level I

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

Thank you so much. Thanks for clearing things up

Highlighted
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;

View solution in original post

Article Labels