cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Mikasa
Level II

having a loop over a column to subset same rows

Hi all

I want to add a section in my script, that create a subset by looking at each row in a column (which are all numbers), find the matched rows and create the subset. and do it only once for a particular value. like if it is 200 in first row, after creating the subset, when in the loop it find another 200, ignores it

I wonder if it is doable in JMP?

Thanks

5 REPLIES 5
txnelson
Super User

Re: having a loop over a column to subset same rows

Here is a different approach that might do the trick for you.  It finds all of the duplicate rows for the different values in a column, and then inverts the selections, which ends up being the first values found for each of the different values in the row.  It then subsets those rows to a new table.

// Subset only the rows where each age appears for the first time
Names Default To Here( 1 );
dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << select duplicate rows( Match( :age ) );

dt << invert row selection;

dtSub = dt << subset(
	selected columns( 0 ),
	selected rows( 1 ),
	output table( "subset" )
);
Jim
Mikasa
Level II

Re: having a loop over a column to subset same rows

Thank you Jim

I think I did a poor job explaining what I want to do. I want all rows matched with the value be in 1 subset.  this script gives me sunset of different value (:Wafer IDs), 1 row for each. 

Basically I want all rows for each wafer ID gives me 1 subset.  the column has different Wafer IDs

Craige_Hales
Super User

Re: having a loop over a column to subset same rows

If you want a separate table for every unique value

tables->subset menu. Multiple tables are opened (see the tabs in this JMP 17 preview)tables->subset menu. Multiple tables are opened (see the tabs in this JMP 17 preview)

That could be a lot of tables opened at once. Usually you don't want to do that; most of the JMP platforms feature a by variable that will run the platform against each by-group. If you do need separate tables, grab the source script for your JSL from one of the subset tables; that script returns a list of the tables it opens. You might also want Keep by columns checked.

Craige
Mikasa
Level II

Re: having a loop over a column to subset same rows

thanks,

My column has many of one particular value, like 200 has repeated more than 10 times. if I want to use match the Rows, then subset it, the source script will give me the all rows numbers. I want to have a script to make a loop to do that for every cell with their matched rows.

Craige_Hales
Super User

Re: having a loop over a column to subset same rows

Use tables->summary to get the unique values and their counts. (You can get a script from that that makes the summary table.) In your script, read the summary table (using for each row), grab the unique value, then select where or get rows where on the main table. Process the selection as needed.

This will not be very different from the previous answer, but it won't make the tables unless you tell it to, and you can decide how many duplicates you care about.

Craige