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

- JMP User Community
- :
- Discussions
- :
- Optimize "for each row"

- 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:
Jan 7, 2020 12:45 AM
| Last Modified: Jan 7, 2020 5:56 AM
(794 views)

Hello,

I have this script on the Big Class table.

On large tables, it takes too much time.

Is there some other quicker way?

```
AgesList = {13,14};
for each row(dt, if(Contains(AgesList ,dt:Name("Age"))>0,dt:Name("height")=-1));
```

Thanks.

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

This might be faster

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
AgesList = {13, 14};
ages_rows = dt << get rows where(contains(ageslist, dt:age));
dt:height[ages_rows] = -1;
```

2 REPLIES 2

Highlighted
##

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

Re: Optimize "for each row"

There are a few unnecessary elements in your script. I do not know if they would add that much time, though. Here is a stripped-down, cleaner version:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
AgesList = {13, 14};
For Each Row(
If( Contains( AgesList, dt:age ),
dt:height = -1;
);
);
```

Learn it once, use it forever!

Highlighted

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

This might be faster

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
AgesList = {13, 14};
ages_rows = dt << get rows where(contains(ageslist, dt:age));
dt:height[ages_rows] = -1;
```

Article Labels

There are no labels assigned to this post.