cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
powerpuff
Level IV

Is it possible to extract the script behind a JMP Table?

For example, we can manually right click on the top-left red icon in a report and hit save script --> To script window. 

Is there a way to do this as a JSL script? This is because I want to manipulate the script to make combined data table further. Thanks for the help.

30 REPLIES 30
Jeff_Perkinson
Community Manager Community Manager

Re: Is it possible to extract the script behind a JMP Table?

That helps a lot. There are still some questions but I think we can help you more now.

Let's take this one step at a time.

Let's get a script working on one data table and then we can worry about generalizing it.

Here's a script that creates three data tables from the Summary of Fit, Analysis of Variance, and Scaled Estimates reports from Fit Model using Big Class.

dt=open("$SAMPLE_DATA\Big Class.jmp");

fm=dt<<Fit Model(
	Y( :weight ),
	Effects( :age, :height, :sex ),
	Personality( "Standard Least Squares" ),
	Set Alpha Level( 0.1 ),
	Emphasis( "Effect Leverage" ),
	Run(
		:weight << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Scaled Estimates( 1 ),
		Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Box Cox Y Transformation( 0 )}
	)
);

rep_fm=report(fm);

rep_fm[Outline Box("Summary of Fit")][Table Box(1)]<<make into data table;
rep_fm[Outline Box("Analysis of Variance")][Table Box(1)]<<make into data table;
rep_fm[Outline Box("Scaled Estimates")][Table Box(1)]<<make into data table;

As you can see, it creates three data tables with different column and row configurations.

JMPScreenSnapz175.png

How do you want these combined into one data table. Concatenating them would result in a strange looking table like this:

JMPScreenSnapz176.png

Without a matching column you can't join them either. So, I'm confused about combining them.

 

 

 

-Jeff
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

Thanks for the help Jeff, I already have it working for one table. Also, I have one column that is same in all the three tables so I will probably join using that column. But I want a more general script that would work for many other tables. Is that possible? Thanks

Jeff_Perkinson
Community Manager Community Manager

Re: Is it possible to extract the script behind a JMP Table?


@powerpuff wrote:

Thanks for the help Jeff, I already have it working for one table. Also, I have one column that is same in all the three tables so I will probably join using that column. But I want a more general script that would work for many other tables. Is that possible? Thanks


I'm not clear how you have a column that is the same from the three report tables that have been made into data tables. 

It's great that you have a script working for one data table that you're ready to generalize. Yes, it's possible to generalize it, but, as shown by the length of this thread, it's difficult to know exactly which part you're struggling with in the abstract. Could you post an example of your script that works on one data table and then we can help point you in the best direction for generalizing it to work with abitrary data tables.

-Jeff
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

Hi Jeff,

This is how my script is:

 

dt=Open("C:\Users\myfile.jmp");
fm = Fit Model(
Y( :Name( "ABC Molecule" ) ),
Effects(
:Name( "ABCD" ),
:Timing 1,
:Timing 2,
:Timing 3,
:Temperature,
:pH,
:Name( "ABCD" ) * :Temperature,
:Name( "ABCD" ) * :pH,
:Timing 2 * :Timing 3,
:Timing 2 * :Temperature,
:Temperature * :pH,
:Name( "ABCD" ) * :Name( "ABCD" ),
:Timing 3 * :Timing 3
),
Personality( "Standard Least Squares" ),
Emphasis( "Minimal Report" ),
Run(
:Name( "ABCD" ) << {Scaled Estimates( 1 ),
Analysis of Variance( 1 ), Parameter Estimates( 1 ),
}
)
);

fmr=fm<<report;
a=fmr["Scaled Estimates"][TableBox(1)]<<Make combined data table;
b=fmr["Summary of Fit"][TableBox(1)]<<Make combined data table;
c=fmr["Analysis of Variance"][TableBox(1)]<<Make combined data table;
row1=nrows(a);
row2=nrows(b);
row3=nrows(c);
vals=Column(a,"Y")[1::row1];
vals2=Column(a,"Term")[1::row1];
vals3=Column(a,"Scaled Estimate")[1::row1];
vals4=Column(c,"F Ratio")[1::row1];
vals5=Column(c,"Prob > F")[1::row1];
vals6=Column(b,"Column 2")[2::2];
d=NewTable("Result",NewColumn("Y",Character,Nominal,Values(vals)),NewColumn("Term",Character,Nominal,Values(vals2)),NewColumn("Scaled Estimate",Numeric,Continuous,Values(vals3)),NewColumn("F Ratio",Numeric,Continuous,Values(vals4)),NewColumn("Prob > F",Numeric,Continuous,Values(vals5)),NewColumn("RSquare Adj",Numeric,Continuous,Values(vals6)));

 

For now, I am just randomly combining columns from these three tables. Can you direct me as to how I can write a more generalized script to accomplish this for different tables? Thanks

 

Jeff_Perkinson
Community Manager Community Manager

Re: Is it possible to extract the script behind a JMP Table?

Thanks, that helps too.

More questions though:

  • I'm still not certain we've gotten to the bottom of what you're trying to accomplish. Is there a particular analysis you're trying to make easy for other people? Are you just trying to speed up something you currently do by hand?
  • Are you looking for the script to run against different source tables? If so, do these tables have the same column names as the table you've built your current script from?
  • If not, is the model form you want to fit using Fit Model fixed? The reason I ask is that the Fit Model launcher dialog is really flexible and I wouldn't want you to try to recreate that.
  • Is your goal to leave the user with the data table of statistics from the Fit Model report? If so, what is the purpose of that? What further analysis do you want the user to do with those statistics in that form?

A couple of other notes.

The process for generalizing a platform script is to replace the column references in a script with script variables and then use New Window() to prompt the user for the columns they would like to use. Again, this is complicated with Fit Model if the model form isn't fixed, so, here's an example using Distribution.

 

Start with the script for Distribution using Big Class:

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dist_list = dt << Distribution( Y( :height, :weight ) );
//Note that the Distribution() returns a list of platforms.
//Therefore I have to index into that list to get the report for one of them

Report( dist_list[1] )[Outline Box( "Summary Statistics" )][Table Box( 1 )] <<
make combined data table;
	

 

Now, I want to generalize it to replace the column references with a JSL variable, in this case y_cols.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

y_cols = {:height, :weight};

//The Eval()below tells JMP to evaluate the variable 
//before evaluating the Distribution(). 
dist_list = dt << Distribution( Y( Eval( y_cols ) ) );

Report( dist_list[1] )[Outline Box( "Summary Statistics" )][Table Box( 1 )] << make combined data table;

Now, I want to use New Window() to prompt the user for the columns to use.

dt=current data table();

//The Column Reference argument for Get Selected was added in JMP 13.1
dist_prompt = New Window( "Choose Columns for Distribution",
	<<Modal,
	V List Box(
		H List Box(
			Panel Box( "Select Columns for Distribution",
				colListData = Col List Box(
					All,
					On Change( y_cols = colListData << Get Selected(Column Reference))
				)
			)
		)
	)
);

dist_list = dt << Distribution( Y( Eval( y_cols ) ) );

Report( dist_list[1] )[Outline Box( "Summary Statistics" )][Table Box( 1 )] << make combined data table;

That's the basic idea for generalizing a script. The answers to the questions above will help you with your specific needs. We'll need those details.

 

-Jeff
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

Hi Jeff, I actually want to save the copying and pasting my team goes through in order to make tables for a final development report. They always have to manually do combined data table and extract columns from each of the tables.
I am looking to run this script against different source tables even though I am not sure if they will have the same column names.
The model form that I want to fit will always be using Fit Model.
My goal is to leave the end user with a table that would have some columns from Analysis of Variance, Summary of fit and Scaled Estimates from the jmp table they would run the script against. It will save them time while writing reports where they wouldn't have to copy-paste from different Jmp reports manually. I hope that makes sense??

Thanks for the help.

txnelson
Super User

Re: Is it possible to extract the script behind a JMP Table?

JSL will certainly allow one to write a generic version of the code.  It is a very powerful language.  I suggest that you start down that path by reading the Scripting Guide

     Help==>Books==>Scripting Guide

and then familiarize yourself with the Scripting Index

     Help==>Scripting Index

It is the Scripting Index that really gives you the details of what all is available with the different objects in JMP.  It also gives you examples of each.

 

Best of luck in your work on the generic version of the code:  Remember, the Discussion Group Community will be there to help you over any issues you run into as you are learning and implementing JSL.

Jim
powerpuff
Level IV

Re: Is it possible to extract the script behind a JMP Table?

Thank you @txnelson I will look into the Scripting guide

Re: Is it possible to extract the script behind a JMP Table?

Generally, JMP objects understand this message, including data tables:

Data Table( "Big Class" ) << Get Script; 

 

David_Burnham
Super User (Alumni)

Re: Is it possible to extract the script behind a JMP Table?

This is a long discussion thread so not sure if you have got your answer - if not, let me know, it can be done - and I have some code I can dig out if it will help

-Dave