cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Due to global connectivity issues impacting AWS Services, users may experience unexpected errors while attempting to authorize JMP. Please try again later or contact support@jmp.com to be notified once all issues are resolved.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
zhouye0
Level II

select matching cells

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

FruitQty
Banana2
Apple5
Apple7
Banana7
Banana1
Banana5
Banana5
Apple8
Pear5
Pear4
1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: select matching cells

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]));

);


View solution in original post

1 REPLY 1
ian_jmp
Level X

Re: select matching cells

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]));

);


Recommended Articles