Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- JSL: How to copy a formula from one data table to another?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 12, 2014 7:57 AM
(7025 views)

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:

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 **)** **)**;

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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 **)** **)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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****()** **)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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