Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
FN
FN
Level V

Filtering row values that are not within a given range (JSL)

I am trying to automate some data cleaning. I have lower and high limit values that are considered valid per column and I want to remove verything else having at the end empty values instead. I am missing:

  • How to clear row values once there is a selection.
  • How to reference a column name
  • If there is a better way to do it.

 

Names Default To Here( 1 );

dt = Current Data Table();

lower_limit = 69.636;
higher_limit = 71.482;

sel = dt << Select Where( :my_column_name>= lower_limit &
	 :my_column_name<= higher_limit  );
	 
sel <<  Invert Row Selection;

// clear rows (sel)??



/*
// Here I am trying to do the same but referencing the column. Yet it does not work.
mycol = Column("my_column_name"); // this does not work
mycol = :my_column_name; //  this does not work either

sel = dt << Select Where( mycol >= lower_limit &
	 mycol <= higher_limit  );

*/
	 
	 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
gzmorgan0
Super User

Re: Filtering row values that are not within a given range (JSL)

Did you wnat to replace the values in that column to empty, or do you wnat to delete the rows?

 

Names Default To Here( 1 );

dt = Open("$sample_data/big class.jmp");

lower_limit = 70;
higher_limit = 150;
mycol = Column("weight");

sel = dt << Get Rows Where ( mycol[] < lower_limit |
	 mycol[] > higher_limit  );
	 
mycol[sel]= empty();

//to delete rows use
// dt << delete rows(sel);

View solution in original post

4 REPLIES 4
Highlighted
gzmorgan0
Super User

Re: Filtering row values that are not within a given range (JSL)

You should look up the Function As Column(). If you want to use column values, the syntax is ref_name[], that is, left bracket, right bracket.  Try the syntax below.

 

sel = dt << Select Where( mycol[] >= lower_limit &
	 mycol[] <= higher_limit  );
Highlighted
FN
FN
Level V

Re: Filtering row values that are not within a given range (JSL)

Excellent, how can I then remove the values of that specific selection (rows and column)?

 

 

Highlighted
gzmorgan0
Super User

Re: Filtering row values that are not within a given range (JSL)

Did you wnat to replace the values in that column to empty, or do you wnat to delete the rows?

 

Names Default To Here( 1 );

dt = Open("$sample_data/big class.jmp");

lower_limit = 70;
higher_limit = 150;
mycol = Column("weight");

sel = dt << Get Rows Where ( mycol[] < lower_limit |
	 mycol[] > higher_limit  );
	 
mycol[sel]= empty();

//to delete rows use
// dt << delete rows(sel);

View solution in original post

Highlighted
FN
FN
Level V

Re: Filtering row values that are not within a given range (JSL)

Thanks, this is what I was looking for. 

 

I have this message in my table, though: Attempt to assign to a locked column mycol.

Article Labels

    There are no labels assigned to this post.