cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
GoodMan
Level III

How to seperate columns into different tables.

I have a datatable with 5 columns. Field names are from from A to Z. Now i want to seperate this table into 5 si gnetables. Every table just contain one column. The table A has one column A. Until the table E ha e one column Z. Can you give me suggestion on JSL?

8 REPLIES 8
txnelson
Super User

Re: How to seperate columns into different tables.

Here is a script that illustrates how to do this.  I strongly suggest that you take the time to read the Scripting Guide from the JMP Documentation Library, available under the Help pull down menu.

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Loop across each column, selecting it and then subsetting
// the data table with all rows and just the selected column
For( i = 1, i <= N Cols( dt ), i++,
	dt << select columns( Column( dt, i ) );
	dt << subset( selected rows( 0 ), selected columns( 1 ) );
	wait(0);
);
Jim
GoodMan
Level III

Re: How to seperate columns into different tables.

Thank you for giving me good suggestion. I will take time to read the guide. I tried your scrip with big class datatable. However it seems to bring back 5 the same tables with 5 columns. Can you help me why? My purpose is to get one col for every table from A to E. 

txnelson
Super User

Re: How to seperate columns into different tables.

I assume the issue is that you are running version 13 or older.  The Select Columns() function did not exist prior to JMP 14.  Here is a different approach that does work.

Names Default To Here( 1 );
// Open Data Table: big class.jmp
// → Data Table( "big class" )
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Loop across each column, specifying a single column on 
// each iteration
For( i = 1, i <= N Cols( dt ), i++,
	dt << subset( selected rows(0), columns(column(dt,i)));
);
Jim
GoodMan
Level III

Re: How to seperate columns into different tables.

Thank you for the explaination. Now it works well. Can you give me a link or pages of guide so that i go to check selected row(0). I can not find here.

 

 

txnelson
Super User

Re: How to seperate columns into different tables.

What version of JMP are you using?
I would examine the entry in the Scripting Index. Look for the Subset
Jim
GoodMan
Level III

Re: How to seperate columns into different tables.

Thank you. I am using 13.
txnelson
Super User

Re: How to seperate columns into different tables.

The documentation in the JMP 13 Scripting Guide is not very helpful, but it does point to the Scripting Index

Subset a Data Table
Subset() creates a new data table from rows that you specify. If you specify no rows, Subset
uses the selected rows. If no rows are selected or specified, it uses all rows. If no columns are
selected or specified, it uses all columns. And if Subset has no arguments, the Subset window
appears.

dt << Subset(
     Columns( columns ),
     Rows( row matrix ),
     Linked,
     Output Table Name( "name" ),
     Copy Formula( 1 or 0 ),
     Sampling rate( n ),
     Suppress Formula Evaluation( 1 or 0 ) );

Note: For more arguments, see the Scripting Index in the Help menu.

 

 

Jim
GoodMan
Level III

Re: How to seperate columns into different tables.

Thank you. I will do some study on your notes.