cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Yngeinstn
Level IV

Table Functions - Multiple tables

I have two problems with I guess JMP assigns tables and uses them later. Steps 2 and 3 will be in separate scripts being called in using the Include() function.

 

// Step 1: Pull in data from server and assign it to dt_testdata_ss

 

dt_testdata_ss = Open Database( <server string>, <query string> , "dt_testdata_ss" );

 

// Step 2: creates new table with conditions

 

dt_testdata_ss_tx = dt_testdata_ss 
    << select where ( (:col_1 == 24) & (:col_2 == 1)) 
    << subset( output table name("dt_testdata_ss_tx"));

 

// Step 2a: uses dt_testdata_ss_tx in graphplot.jsl

 

// Step 2b: uses dt_testdata_ss_tx in distribution.jsl

 

// Step 3: creates new table with conditions

 

dt_testdata_ss_rx = dt_testdata_ss 
    << select where ((:col_1 == 16) & (:col_2== 3 )) 
    << subset( output table name( "dt_testdata_ss_rx"));

 

// Step 3a: uses dt_testdata_ss_rx in graphplot.jsl

 

// Step 3b: uses dt_testdata_ss_rx in distribution.jsl

 

I now have 3 tables open at the same time and i can't call in the correct table to the script that you provided. I even went as far as

 

dt_testdata_ss
dt_testdata_ss_tx
dt_testdata_ss_rx

 

When i run your script i am getting the following error when i run it with changing dt to dt_testdata_tx or dt_testdata_rx:

 

ERROR: invalid argument in access or evaluation of 'Close' , Close *###*/(dtSum, nosave)

 

I can only assume that dt is not being assigned to dt_testdata_tx or dt_testdata_rx because the table doesn't execute. I can't figure out how to call in a certain table to manipulate if all 3 are open. Suggestions?

 

Thanks in advance

 

dt = current data table(); // removed this line
dtsum = dt // changed dt to either dt_testdata_ss_tx or dt_testdata_ss_rx
dtFinal = dt // changed dt to either dt_testdata_ss_tx or dt_testdata_ss_rx
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Table Functions - Multiple tables

If I am correctly interpreting your issue, I believe that you are not quite getting how the variables that are pointing to the data tables are working, and how to use them.  I have put together a very simple script, that creates 3 different data tables.  It then goes on and produces an analysis on each of the different data tables, in an order that is different than the order they were created.  I used the data table pointer variables to accomplish this.  I then have also included a comment section illustrating how to accomplish this same order of output if you choose to reset the current data table, before running the analysis.

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

dt << select where( :sex == "F" );

dtFemale = dt << subset( selected rows( 1 ), selected columns( 0 ) );

dt << invert row selection;

dtMale = dt << subset( selected rows( 1 ), selected columns( 0 ) );

dtFemale << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
dtMale << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
dt << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);

// Or

/*current data table( dtFemale );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
current data table( dtMale );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
current data table( dt );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);*/
Jim

View solution in original post

pmroz
Super User

Re: Table Functions - Multiple tables

Names default to here(1) makes all variables local.  If you want to have all variables be global then leave this line out.

 

Otherwise you could pass them using global variables.  A global variable in JSL starts with two colons "::".  I add g_ to denote that this is a global variable.

::g_dt_testdata_ss_tx = foo bar ...

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Table Functions - Multiple tables

If I am correctly interpreting your issue, I believe that you are not quite getting how the variables that are pointing to the data tables are working, and how to use them.  I have put together a very simple script, that creates 3 different data tables.  It then goes on and produces an analysis on each of the different data tables, in an order that is different than the order they were created.  I used the data table pointer variables to accomplish this.  I then have also included a comment section illustrating how to accomplish this same order of output if you choose to reset the current data table, before running the analysis.

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

dt << select where( :sex == "F" );

dtFemale = dt << subset( selected rows( 1 ), selected columns( 0 ) );

dt << invert row selection;

dtMale = dt << subset( selected rows( 1 ), selected columns( 0 ) );

dtFemale << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
dtMale << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
dt << Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);

// Or

/*current data table( dtFemale );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
current data table( dtMale );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);
current data table( dt );
Oneway(
	Y( :height ),
	X( :age ),
	Means and Std Dev( 1 ),
	Mean Error Bars( 1 ),
	Std Dev Lines( 1 )
);*/
Jim
pmroz
Super User

Re: Table Functions - Multiple tables

You're pretty close.  For the subset command there's no need to name the table.  Simply assigning it to a variable is enough.  But you should specify how you want the subset to work with selected rows(1), selected columns(0).

 

Not sure why close(dtsum, nosave) is not working, provided that you assigned dtsum = (one of the table variables).

 

Regarding dt = current data table() - I wouldn't use this because you have three tables open, and which table is current might not be clear.  Better to just use your existing table variables.

// Step 1: Pull in data from server and assign it to dt_testdata_ss
dt_testdata_ss = Open Database( <server string>, <query string> , "dt_testdata_ss" );

// Step 2: creates new table with conditions
dt_testdata_ss_tx = dt_testdata_ss << select where ( (:col_1 == 24) & (:col_2 == 1 )) 
	<< subset( selected rows( 1 ), selected columns( 0 ));
// Step 2a: uses dt_testdata_ss_tx in graphplot.jsl
// Step 2b: uses dt_testdata_ss_tx in distribution.jsl

// Step 3: creates new table with conditions
dt_testdata_ss << clear row states;	// Remove prior selec
dt_testdata_ss_rx = dt_testdata_ss << select where ( (:col_1 == 16) & (:col_2 == 3 ))
	<< subset( selected rows( 1 ), selected columns( 0 ));
// Step 3a: uses dt_testdata_ss_rx in graphplot.jsl
// Step 3b: uses dt_testdata_ss_rx in distribution.jsl
Yngeinstn
Level IV

Re: Table Functions - Multiple tables

I think it had to be how the tables/variables were being assigned. It's the simple things that cause the most problems..

 

A calculus problem what is wrong because of a simple math error.. Thank you very much for the explination..

 

 

Yngeinstn
Level IV

Re: Table Functions - Multiple tables

This works great thank you.. I actually found a slight problem with my script that wouldn't allow me to change tables..

 

Now my issue is that i have 4 open tables and they will be used individually in an Include() script.. I can't figure out how to select the data table in the new script.. It seems that the variables are not being passed through to the new script..

 

If I have 4 table names does this Names To Default Here(1); store it just on the data table variables in that script that originated them? I have tried Names To Default Here(0); which i thought assigned it globally...

 

Any suggestions?

 

Thanks

 

pmroz
Super User

Re: Table Functions - Multiple tables

Names default to here(1) makes all variables local.  If you want to have all variables be global then leave this line out.

 

Otherwise you could pass them using global variables.  A global variable in JSL starts with two colons "::".  I add g_ to denote that this is a global variable.

::g_dt_testdata_ss_tx = foo bar ...