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
jumper
Level I

JSL: How to copy a formula from one data table to another?

I need to copy a formula from one data table to another.

The only suggestion I found and managed to get to work is this:

Copy Columns With Formulas


The easiest way is to get the script for the original data table.



data table("Original") << get script;



Now the script appears in the log.  Just copy and paste into a new script, keeping only the bits related to adding the the formula columns. 


which seems, however, very convoluted and time-consuming when I need to apply it multiple times.

This other method was suggested here: Saving the prediction formula to an existing column?


f = column("prednew") << Get Formula;


column("predold") << Set Formula( Name Expr( f ));


so I tried:


f = data table("table 1") << column("my formula") << Get Formula;


data table("table 2") << column("my formula") << Set Formula( Name Expr( f ));


where 'my formula' already exists, but is empty, in table 2

but it doesn't work, and the log gives no errors.

Any ideas? Is this documented anywhere in JMP's official documentation?

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL: How to copy a formula from one data table to another?

Get Formula() and Set Formula() are documented, whereas your syntax is probably not. Column() cannot be used as a message to a data table. Use instead the first argument of Column() to specify the data table.

f = Column( Data Table( "table 1" ), "my formula" ) << Get Formula;

Column( Data Table( "table 2" ), "my formula" ) << Set Formula( Name Expr( f ) );

View solution in original post

4 REPLIES 4
ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL: How to copy a formula from one data table to another?

Get Formula() and Set Formula() are documented, whereas your syntax is probably not. Column() cannot be used as a message to a data table. Use instead the first argument of Column() to specify the data table.

f = Column( Data Table( "table 1" ), "my formula" ) << Get Formula;

Column( Data Table( "table 2" ), "my formula" ) << Set Formula( Name Expr( f ) );

jumper
Level I

Re: JSL: How to copy a formula from one data table to another?

I couldn't get the method in your other post to work, but this works perfectly - thank you.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: JSL: How to copy a formula from one data table to another?

Another option is to use Get Column Properties() followed by Add Column Properties() to copy all properties, incl. formula. No need for Name Expr() when using this approach.

oldcol = Column( Data Table( "table 1" ), "my formula" );

newcol = Column( Data Table( "table 2" ), "my formula" );

newcol << Add Column Properties( oldcol << Get Column Properties() );

nascif_jmp
Level VI

Re: JSL: How to copy a formula from one data table to another?

Coming a few years later to the party :)

You might also want to consider the Formula Depot, a feature added to JMP Pro 13, that is designed to help this kind of scenario.

It allows you to save (we call it "publish" in this case) a model (any formula, actually) to a central place from where it can be added to other tables - as well as converted to different languages for deployment, compared to other models, profiled, and so on.

Check it out:

http://www.jmp.com/support/help/13/Formula_Depot.shtml