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
- :
- Cannot create a column formula dynamicly

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

Highlighted
##
##### Cannot create a column formula dynamicly

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

May 31, 2012 5:53 PM
(1146 views)

I am an intermediate user and I am trying to create 50 columns with unique formulas based product specs.

I have succeesfuly created a strng variable withthe formula in it but I cannot get inot the column in a manner that works:

When I view the variable min_Form it shows the exact formula that I want to insert but when I inert it the column formula shows "min_form" and not the actual string that I was hoping for.

Any ideas on how to get the contents of the variable inserted instead of the variable name?

//Need to create formulas as character strings before inerting into formula field of new column

Minspec=char(":" || char(temp_Srow) || "_MinMarg");

maxspec=char(":" || char(temp_Srow) || "_MaxMarg");

min_Form="If(" || maxspec ||" < 0 | " || Minspec || " < 0,1,

Empty()

);

)";

// Max Only

if (is missing(temp_SpecMin),

dtMM<< New Column(Char(temp_Mcol() || "_Fail"),

character,

formula(min_Form)

);

matchflag = 1;

Break(); // Go to next spec

);

Thank you in advance,

Jeff

4 REPLIES

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

Jun 1, 2012 5:25 AM
(989 views)

Here's one way to do it. Basically you build the entire new column expression and run it through eval(parse()).

dt = open**(**"$sample_data\big class.jmp"**)**;

my_formula = ":Age * :Height / :Weight";

new_column_expr = "dt << new column(\!"Test\!", numeric, continuous, formula(" || my_formula || "))";

eval**(**parse**(**new_column_expr**))**;

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

Jun 1, 2012 6:09 AM
(989 views)

Thanks PMroz,

I am almost done.

I can get the formula in now.

The last issue I am having is in formatting the text true result in my if statement:

="If(" || maxspec ||" < 0 | " || Minspec || " < 0," || temp_Srow || ",Empty());";

The issue is the caracter string temp_Srow.

assume temp_srow="Hi"

I want it to show up as "Hi" in the results but it shows up as Hi without the quotes and when I use \! around it I get "temp_srow" in the formula result.

Thanks,

Jeff

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

Jun 1, 2012 6:14 AM
(989 views)

Try adding an extra quotation outside temp_Srow with \!:

"If(" || maxspec ||" < 0 | " || Minspec || " < 0,\!"" || temp_Srow || "\!",Empty());";

Adam

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

Jun 1, 2012 6:18 AM
(989 views)

Adam,

That worked.

Thanks for your help!

Jeff