cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Jemster
Level III

Loop for Deleting Rows

I have a loop for deleting rows where the column value isn't what I want

When I run the loop I keep the first set of rows meeting my specifications then it deletes all other rows. I am importing from an excel file and it has several rows in succession of what I want then a gap with other data then later another several. I only get the first set

N_loop = N Rows(dt_a);
i_loop = 0;

While(N_loop > i_loop,
	If( And(dt_a:Column 7[N_loop] != "example 1", dt_a:Column 7[N_loop] != "example 2"),
		dt_a << Delete Row(N_loop)
	);
	N_loop = N_loop - 1
);

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

View solution in original post

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim

View solution in original post

2 REPLIES 2
Jemster
Level III

Re: Loop for Deleting Rows

The code works fine. I was searching in the wrong column

txnelson
Super User

Re: Loop for Deleting Rows

You might also try

select where( dt_a:Column 7[N_loop] != "example 1" & dt_a:Column 7[N_loop] != "example 2" );
dt_a << delete rows;
Jim

Recommended Articles