cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
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
Staff

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
Staff

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

);