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
- :
- Use a Variable for a column in Set Formula()

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

Apr 12, 2012 1:50 PM
(1357 views)

Using JMP 9.0.2 on Windows XP 32Bit

I want to produce a script which sets the formula of the column "Formula Column" to <<(:My Column) + 1>>. I need to reference "My Column" with a variable though. The following script makes the formula <<Eval(col) + 1>> which is meaningless...

col = column("My Column");

:Formula Column<<set formula(eval(col)+1);

1 ACCEPTED SOLUTION

Accepted Solutions

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

Apr 12, 2012 3:57 PM
(2272 views)

Solution

There may be a simpler way, but this works in JMP 9 (Mac):

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

col=Column**(**"height"**)**<<get name;

newcol=dt<<new column**(**"Formula Column", formula**(**eval**(**evalexpr**(**expr**(**parse**(**col**))**+**1****))))**;

4 REPLIES

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

Apr 12, 2012 3:57 PM
(2273 views)

There may be a simpler way, but this works in JMP 9 (Mac):

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

col=Column**(**"height"**)**<<get name;

newcol=dt<<new column**(**"Formula Column", formula**(**eval**(**evalexpr**(**expr**(**parse**(**col**))**+**1****))))**;

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

Apr 13, 2012 5:49 AM
(1136 views)

Thanks. For me I just needed:

newcol=dt<<new column**(**"Formula Column", formula**(**eval**(****(**parse**(**col**))**+**1****)))**;

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

Apr 13, 2012 6:47 AM
(1136 views)

**(**"height"**)**;. It would be much nicer if the formula changed to <<:height + 1>> so that it worked even if 'col' is being used for something else. Maybe too much to ask...

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

Apr 13, 2012 6:52 AM
(1136 views)