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
Ole
Ole
Level III

Using dt << select where() in for loop while looping through columns

Hi,

 

I'm trying to run a similar script like below where I loop through a list of columns, select where they meet a certain criteria and hide/exclude them accordingly.

 

In my script there are calculations and graphical outputs created and for all of those I'm able to use the approach to select a column and compute it as I show below. 

Except for the select where() part:

- If I use the :column(col_w) it ignores it

- If I use :name(col_w) it gives an error that it needs a quoted string and I can't get it to work.

 

How would I properly script it to get the select where to work?

 

Thanks

Ole

 

 
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col_w = List( "age", "height", "weight" );
For( i = 3, i <= N Items( col_w ), i++, 
    //i = 1;
	cur_col = (col_w[i]);
    //cur_col1 = column(col_w[i]);
	dt << select where( :column( cur_col ) > 1 ) << hide;
	<<exclude;
    //dt << select where ( :name(cur_col) > 1) << hide; << exclude;
);
 
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Using dt << select where() in for loop while looping through columns

Your For() loop needs to start with I=1.

Here is the proper form for your Select Where:

dt << select where ( as column(cur_col) > 1); column(dt,cur_col) << hide << exclude;
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Using dt << select where() in for loop while looping through columns

Your For() loop needs to start with I=1.

Here is the proper form for your Select Where:

dt << select where ( as column(cur_col) > 1); column(dt,cur_col) << hide << exclude;
Jim
Ole
Ole
Level III

Re: Using dt << select where() in for loop while looping through columns

Perfect. Thanks. It works now.

I had set the i = 3 as I only wanted to look at one loop to understand the issue and that was the easiest way to do so. But thanks for mentioning it. These little (potential) mistakes can cost one hours to find ...