- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Subsetting a data table into several data tables by column value
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content