BookmarkSubscribeRSS Feed

Setting Column Formulae with JSL

Hi everyone,

I am using JMP 7 on Windows XP.

I am writing a script that will let the user select an arbitrary set of columns from a data table and then do some calculations on them. In this process, new columns need to be created for each initially selected column, and the formula for the new column is dependent on the old column.

As an example, if I had a data table with columns A-J, and the user selected columns B,C, & D to do these calculations. I want to be able to do something similar to the following:

So, my desired outcome would be my orignal table plus 3 new columns (New_B, New_C, New_D)*. The formula for New_B I would like is :B +10. I get as far as creating the new column so I know the reference col works, but when I try to set the formula I get an error saying it can't convert the argument to a number. I can't specify :B directly because the inputs are arbitrary; ColumnList could just as easily be {D,G,I,J}.

I believe I could go through each row and set each value manually with another for loop, but I'm concerned that would really slow down my calculations. Plus, assuming that the JMP platforms are written in JSL, there must be some way to do this, since there is the Save Prediction Formula function in the Fit Model report that creates formulae with references to other columns. Does anyone know how to do this?

Thanks in advance.

* I also used munger to get rid of the : in the name string, but I thought that might confuse matters for the purposes of the post.



Jun 23, 2011

Re: Setting Column Formulae with JSL

Here's one way to create the loop:

Re: Setting Column Formulae with JSL

Thanks so much. That fixed it wonderfully.

I have another related question now. I have all of these columns, but I need to create another column whose formula is a function of all of these new columns. So something like:

NextCol << Set Formula(:New_A + :New_B + :New_D)

Or more complicated like:

NextCol << Set Formula(sqrt((:New_A-5)^2+(:New_B-26)^2))

How can I do that arbitrarily? I tried creating an expression and using InsertInto with the Parse command, but I couldn't get it to evaluate once I got all the terms in.