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
- :
- Discussions
- :
- select matching cells

Topic Options

- Start Article
- 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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 25, 2016 3:01 AM
(4835 views)

**by the end of the thing, my expected output should be 3 subset tables.**

So I want to do this:

1) Go to a specific column,

2) Go to the first row of the column, and select matching cells, and group them to a subset table

dt << Select Matching Cells;

3) Then I want to skip the rest of the cell that I have matched, and move on to the next unique cell, and select the matching cells, and group them to a new subset table.. How do I do that? My table looks something like this

Fruit | Qty |
---|---|

Banana | 2 |

Apple | 5 |

Apple | 7 |

Banana | 7 |

Banana | 1 |

Banana | 5 |

Banana | 5 |

Apple | 8 |

Pear | 5 |

Pear | 4 |

1 ACCEPTED SOLUTION

Accepted Solutions

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

There are many ways to do this in JSL, but here's one:

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

// Sample Data

dt = NewTable**(**"Sample Data",

NewColumn**(**"My Col", Numeric, Nominal, Formula**(**RandomInteger**(****4****)))**,

AddRows**(****50****)**

**)**;

// Get unique values

uVals = AssociativeArray**(**:My Col << **getValues****)** << **getKeys**;

// Make Subset Tables

for**(**g = **1**, g <= NItems**(**uVals**)**, g++,

r2get = dt << **getRowsWhere****(**:My Col == uVals**[**g**])**;

dt2 = dt << **subset****(**Rows**(**r2get**))**;

dt2 << **setName****(**"Subset of "||**(**dt << **getName****)**||" with My Col = "||Char**(**uVals**[**g**]))**;

**)**;

1 REPLY 1

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

There are many ways to do this in JSL, but here's one:

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

// Sample Data

dt = NewTable**(**"Sample Data",

NewColumn**(**"My Col", Numeric, Nominal, Formula**(**RandomInteger**(****4****)))**,

AddRows**(****50****)**

**)**;

// Get unique values

uVals = AssociativeArray**(**:My Col << **getValues****)** << **getKeys**;

// Make Subset Tables

for**(**g = **1**, g <= NItems**(**uVals**)**, g++,

r2get = dt << **getRowsWhere****(**:My Col == uVals**[**g**])**;

dt2 = dt << **subset****(**Rows**(**r2get**))**;

dt2 << **setName****(**"Subset of "||**(**dt << **getName****)**||" with My Col = "||Char**(**uVals**[**g**]))**;

**)**;