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

Showing results for

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

- 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
(2261 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

Solution

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

3 REPLIES

- 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

Oct 13, 2014 10:46 AM
(1161 views)

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

Oct 12, 2014 12:27 PM
(1161 views)

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