cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
Mickyboy
Level V

how to replace a numeric value in a variable

Hi All,

 

this might be very easy so forgive me, i am trying to replace a numeric value in a variable with another value and am trying to do so with the following syntax

 

Acc << select where( :lo50%expGMT > 10.0 );
Acc << replace (5);

 

this deletes the whole row rather then replace any values under 10 with 5.

 

Can anyone help me?????

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: how to replace a numeric value in a variable

You did not copy the formula correctly.  It is:

Acc << New Column( "lo50%expGMT", Numeric, Continuous, Formula(If(round(:expGMT / 2 ) >= 10,round(:expGMT / 2 ), 5)));

Please review the structure of an IF() clause in the Scripting Guide

     Help==>Books==>Scripting Guide

There are 3 sections to an IF() clause.

     If( comparison, what to do if the comparision is true, what to do if the comparison is not true);

Therefore:

If(     round(:expGMT / 2 ) >= 10 // The comparision
 
  ,round(:expGMT / 2 ) // What to do if true
 
    , 5  // what to do if not true
 
)));
Jim

View solution in original post

14 REPLIES 14
txnelson
Super User

Re: how to replace a numeric value in a variable

Assuming that "Acc" is the pointer to the data table, and that "Acc:lo50%expGMT" is the name of the column that you both want to compare with and then change it"s value, the following code will change the values

:Name("Acc:lo50%expGMT" )[Acc << get rows where( :Name("lo50%expGMT") > 10.0 )] = 5;

I choose to use the :Name() function in the code, since the column name contains a special character "%" that JMP may get confused over.

Jim
Mickyboy
Level V

Re: how to replace a numeric value in a variable

Thanks Jim, l really appreciate it, will try it at work tomorrow

Mickyboy
Level V

Re: how to replace a numeric value in a variable

Hi Jim,

 

My apologies, l am new to JMP so struggling a little bit with the Syntax, this didnt work either, Acc is the pointer to the data table "Accuracy" and the name of the variable is lo50%expGMT.

txnelson
Super User

Re: how to replace a numeric value in a variable

Oops...I had an error...try this

Acc:Name("lo50%expGMT" )[Acc << get rows where( :Name("lo50%expGMT") > 10.0 )] = 5
Jim
Mickyboy
Level V

Re: how to replace a numeric value in a variable

Sorry Jim, still didnt work

Mickyboy
Level V

Re: how to replace a numeric value in a variable

l think the problem is that the variable lo50%expGMT has a formula and is derivied by dividing another variable by 2, would this matter??

txnelson
Super User

Re: how to replace a numeric value in a variable

The fact that lo50%expGMT is a column created with a formula will not make any differenct

What messages are you seeing in the log?

 

If you run just the following JSL, you will see the results in the log.  It should just give you a matrix with the row numbers for all of the rows where lo50%expGMT is greater than 10

 

Acc << get rows where( :Name("lo50%expGMT") > 10.0 );

 Can you  attach a sample data table?

Jim
Mickyboy
Level V

Re: how to replace a numeric value in a variable

1 12 10.684 1645 1645 823 3290 Pass
2 12 9.4540 701 823 412 1646 Pass
4 12 8.4053 339 411 206 822 Pass
8 12 7.4053 170 206 103 412 Pass
16 12 6.4053 85 103 52 206 Pass
32 12 5.3707 41 51 26 102 Pass
64 12 4.3707 21 26 13 52 Pass
128 12 2.4886 6 13 7 26 Fail

it hasnt selected the row in question, the one in question is the last row, the variable in question is lo50%expGMT, which the forth from the left.

Mickyboy
Level V

Re: how to replace a numeric value in a variable

Sorry that should be the 6th from the left