cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Abby_Collins14
Level III

How to reference already open data table (from multiple open data tables) JSL

I am working on writing scripts that create different reports and data tables. However, I always have to end up running them chunk wise and manually clicking on the drop down menu to select the data table I want to run the given chunk of script on. 

I am familiar with the current data table() function, but not really anything else that doesn't require a file path. 

 

Does anyone know any easy way to reference or select a different already open data table, perhaps by name or something?

 

Thanks!

3 REPLIES 3
txnelson
Super User

Re: How to reference already open data table (from multiple open data tables) JSL

Any data table can be referenced by using the Data Table() function.  Such as:

Data Table("Big Class") << Bivariate( X(:height), Y(:weight) );

One can also set a variable equal to a data table when it is created, and if the variable isn't changed in the script, it will always reference the table it was linked to.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
dt << select where( :sex == "F" );

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

rpt = New Window( "Subset of big class - Distribution of height, weight",
	dtFemale << Distribution(
		Continuous Distribution( Column( :height ), Process Capability( 0 ) ),
		Continuous Distribution( Column( :weight ), Process Capability( 0 ) )
	)
);
Wait( 0 );
dtStats = rpt["Distributions", "height", "Summary Statistics", Table Box( 1 )] <<
Make Combined Data Table;
rpt << Close Window;

dtStats << Tabulate(
	Change Item Label( Statistics( Sum, "Stats" ) ),
	Remove Column Label( Analysis Columns( Column 2 ) ),
	Show Control Panel( 0 ),
	Add Table(
		Column Table( Analysis Columns( :Column 2 ) ),
		Row Table( Grouping Columns( :Y, :Column 1 ) )
	)
);

Other methods can be used.  If you would provide a sample of the code you are using, additional help may be available.

Jim
matth1
Level IV

Re: How to reference already open data table (from multiple open data tables) JSL

If you still wanted to interactively choose which table you run a script on, but wanted it to be a bit more robust, you could do something like this:

names default to here(1);

// Open a couple of tables for demo purposes
dt1 = open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );
wait(0);

table_names = {};
For( i = 1, i <= N Table(), i++,
	Insert Into( table_names, Data Table( i ) << get name );
);
If( N Items( table_names ) > 0, 
	tabSelect = New Window( "Select Table For Use",
		<<Modal,
		<<Return Result,
		Lineup Box( N Col( 1 ),
			Text Box( "Select table for use for your script" ),
			t1 = Combo Box( table_names ),
			H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )
		)
	);
	If( tabSelect["button"] == -1,
		Throw( "Run chart script cancelled." )
	);
,
	Throw( "No data tables found." )
);

dt = Data Table( table_names[tabSelect["t1"]] );

print( "Selected data table: " || char( dt << get name ) );
// Rest of script here
// Use dt as the reference for the table you want to analyse.
BeckettHill
Level I

Re: How to reference already open data table (from multiple open data tables) JSL

Thank you.