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
- :
- Best way to script a column formula into many colu...

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

Apr 3, 2015 4:51 PM
(4225 views)

I need to apply a formula to many columns. What is the best way to script this?

For example, I want to apply this formula to each column of the Football.jmp table:

New Column**(** "Height Rank from mean",

Numeric,

"Continuous",

Format**(** "Best", **12** **)**,

Formula**(** Col Rank**(** Abs**(** Col Mean**(** :Height **)** - :Height **)** **)** **)**

**)**

I've tried a few things - none great. I could either select the columns by hand, or use a dialog. Thank you!

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Apr 4, 2015 11:49 AM
(6002 views)

Solution

One way is to make a list with the desired column names and loop over that list, making a new formula column with each iteration:

dt = Data Table**(**"Football.jmp"**)**;

cols = dt << **get column names****(**Numeric**)**; //List of all numeric columns

// uncomment row below to select columns by hand instead

// cols= dt<<get selected columns;

For**(**i = **1**, i <= N Items**(**cols**)**, i++,

F = Eval Expr**(**Col Rank**(**Abs**(**Col Mean**(**Expr**(**cols**[**i**]))** - Expr**(**cols**[**i**]))))**;

dt << **New Column****(**cols**[**i**]** << **get name** || " Rank from mean",

Numeric,

"Continuous",

Format**(**"Best", **12****)**,

Formula**(**Name Expr**(**F**))**

**)**;

**)**;

1 REPLY

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Apr 4, 2015 11:49 AM
(6003 views)

One way is to make a list with the desired column names and loop over that list, making a new formula column with each iteration:

dt = Data Table**(**"Football.jmp"**)**;

cols = dt << **get column names****(**Numeric**)**; //List of all numeric columns

// uncomment row below to select columns by hand instead

// cols= dt<<get selected columns;

For**(**i = **1**, i <= N Items**(**cols**)**, i++,

F = Eval Expr**(**Col Rank**(**Abs**(**Col Mean**(**Expr**(**cols**[**i**]))** - Expr**(**cols**[**i**]))))**;

dt << **New Column****(**cols**[**i**]** << **get name** || " Rank from mean",

Numeric,

"Continuous",

Format**(**"Best", **12****)**,

Formula**(**Name Expr**(**F**))**

**)**;

**)**;