cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

Subsetting a data table into several data tables by column value

Feli
Level IV

Dear Community,

I want to split my data table into several smaller data tables that contain only the rows where a column has a certain value. This I want to do for all unique values of the column.

 

With the example of the Big Class data: I want to generate two data tables in which one has only the rows where sex= F and the other the rows where sex = M. They have to be two separate data tables.

 

With only a few value categories I could do it by hand by selecting/data filtering the rows and only subsetting the selected rows, but with over 50+ categories I am probably looking at a scripting option since point and click will take too long.

 

Any help? I guess I would need to find a way to loop over the unique values of my separation column and try to reproduce the subsetting?

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User


Re: Subsetting a data table into several data tables by column value

Tables=>Subset has a Subset By checkbox that when checked, allows for the creation of a new subset for each level of the column(s) selected in the subset selection box

subset.PNG

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User


Re: Subsetting a data table into several data tables by column value

Tables=>Subset has a Subset By checkbox that when checked, allows for the creation of a new subset for each level of the column(s) selected in the subset selection box

subset.PNG

Jim
Georg
Level VII


Re: Subsetting a data table into several data tables by column value

In addition to @txnelson ,

when having so many tables, you may need to organize and change them in lists, see example.

Names Default To Here( 1 );

cdt = Open( "$SAMPLE_DATA\Big Class.jmp" );

tables = cdt << Subset(
	By( :age ),
	All rows,
	Selected columns only( 0 ),
	columns( :name, :age, :height, :weight )
);
Wait( 3 );

For( i = 1, i <= N Items( tables ), i++,
	write( "closing: ", tables[i] << get name , "\!n");
	wait(1);
	Close( tables[i], NoSave );
);
Georg
Feli
Level IV


Re: Subsetting a data table into several data tables by column value

Wow. How did I not know that?? That's exactly what I wanted. Thanks, @txnelson!