Turn on suggestions

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

Showing results for

- JMP User Community
- :
- Discussions
- :
- How can I find rows that have elements of my list ?

Topic Options

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

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

Feb 17, 2016 8:59 AM
(5559 views)

Hello All,

I am wondering as to what is the best way to achieve this. I have a list of elements and a data table . I want to figure out the easiest way to select all rows in one column that have the elements of my list (inclusive of duplicates) . The code that I am using is :

for**(**i = **1**, i<= N Items**(Check**List**)**,i++,

dt_List << **Select Where(**Pat Match**(**:ColName,CheckList**[**i**])** == **1)**;

dt_List << Label ;

**)**;

dt_List << **Select Labelled Rows** ;

where CheckList - is my list for e.g. CheckList = {1,2,3,4} ;

:ColName - is the name of my column

dt_List - is the name of the data table I am working with

The above piece of code only selects only the rows for the last item of my list . However , the label shows up on the appropriate rows.

Best

Uday

Best

Uday

Uday

1 ACCEPTED SOLUTION

Accepted Solutions

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

I'm a little nervous over the use of the word 'best' above, but here's one way:

NamesDefaultToHere**(****1****)**;

dt = Open**(**"$SAMPLE_DATA/Big Class.jmp"**)**;

// Make a list of unique ages, removing a couple of items at random

mylist = AssociativeArray**(**Column**(**dt, "age"**)** << **getValues****)** << **getKeys**;

RemoveFrom**(**myList, RandomInteger**(****1**, NItems**(**myList**))**, **1****)**;

RemoveFrom**(**myList, RandomInteger**(****1**, NItems**(**myList**))**, **1****)**;

Print**(**myList**)**;

// Select the requisite rows

r = dt << **getRowsWhere****(**Contains**(**myList, :age**))**;

dt << **selectRows****(**r**)**;

2 REPLIES 2

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

I'm a little nervous over the use of the word 'best' above, but here's one way:

NamesDefaultToHere**(****1****)**;

dt = Open**(**"$SAMPLE_DATA/Big Class.jmp"**)**;

// Make a list of unique ages, removing a couple of items at random

mylist = AssociativeArray**(**Column**(**dt, "age"**)** << **getValues****)** << **getKeys**;

RemoveFrom**(**myList, RandomInteger**(****1**, NItems**(**myList**))**, **1****)**;

RemoveFrom**(**myList, RandomInteger**(****1**, NItems**(**myList**))**, **1****)**;

Print**(**myList**)**;

// Select the requisite rows

r = dt << **getRowsWhere****(**Contains**(**myList, :age**))**;

dt << **selectRows****(**r**)**;

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

Re: How can I find rows that have elements of my list ?

Ian@JMP :

Thanks for your response. I have found the following helpful too :

MyList = {"611","680","323","410"};

dt << select where(contains(MyList, char(:ColName)));

Alternatively :

dt << Select Where(Pat Match(:ColName,CheckList[i]) == 1, current selection("extend"));

These were suggestions I received from other resources and I hope it will help the next guy .

Best

Uday

Best

Uday

Uday