Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- Using dt << select where() in for loop while looping through columns

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Feb 22, 2020 9:34 AM
| Last Modified: Feb 24, 2020 4:46 AM
(1148 views)

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

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

2 REPLIES 2

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Article Labels

There are no labels assigned to this post.