Choose Language Hide Translation Bar
Highlighted
ptkguy
Level II

Use a Variable for a column in Set Formula()

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
ms
Super User ms
Super User

Re: Use a Variable for a column in Set Formula()

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

View solution in original post

4 REPLIES 4
ms
Super User ms
Super User

Re: Use a Variable for a column in Set Formula()

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

View solution in original post

Highlighted
ptkguy
Level II

Re: Use a Variable for a column in Set Formula()

Thanks. For me I just needed:

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

Highlighted
ptkguy
Level II

Re: Use a Variable for a column in Set Formula()

The only problem with this approach is that is leaves the formula in the 'Formula Column' as <<col + 1>>, which only works as long as col=Column("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...

Highlighted
ms
Super User ms
Super User

Re: Use a Variable for a column in Set Formula()

Yes, I noticed and removed the post quickly. Sorry for the confusion. Formula(Ascolumn(col)...) only works as long the global col is not cleared.

Article Labels

    There are no labels assigned to this post.