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
- :
- JMP script question

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

Jul 10, 2011 8:09 PM
(778 views)

I'm a new user trying to learn JMP script. I've a very simple script but encountered an expected result. May be someone can give me a pointer on what did I do wrong here. Thanks in advance. (BTW: I'm using JMP 8.02)

I have a very simple table as below (test1.csv):

Tool_first | Tool_second | Process_time | Tool_third | Group_1 | Real_beta | Base |

A | C | 4/3/2011 0:53 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 1:08 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 5:27 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 6:26 | E | A-E | 0.0058 | Y |

A | D | 4/3/2011 6:39 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 6:49 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 18:43 | E | A-E | 0.0058 | Y |

A | C | 4/3/2011 23:42 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 5:20 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 8:34 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 10:43 | E | A-E | 0.0058 | Y |

A | D | 4/4/2011 11:02 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 13:57 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 14:28 | E | A-E | 0.0058 | Y |

A | D | 4/4/2011 16:43 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 20:01 | E | A-E | 0.0058 | Y |

A | C | 4/4/2011 20:17 | E | A-E | 0.0058 | Y |

A | D | 4/4/2011 21:45 | E | A-E | 0.0058 | Y |

A | C | 4/5/2011 18:20 | E | A-E | 0.0058 | Y |

A | D | 4/5/2011 20:02 | E | A-E | 0.0058 | Y |

A | C | 4/5/2011 20:35 | E | A-E | 0.0058 | Y |

The following script reads in the .csv file and added two more columns to the table based on comparison of one row with its previous row. My script is below

Source_Table=Open ("c:\test1.csv");

Source_Table <<Sort(By(group_1, process_time), order(Ascending), Replace Table);

new column("Inspect_pt",

formula(

if(row()==1,1,

(:group_1[row()] != :group_1[row()-1]),1,

(:group_1[row()] == :group_1[row()-1]),0)));

new column("tool_Change",

formula(

if(row()==1,1,

(:tool_second[row()] != :tool_second[row()-1]),1,

(:tool_second[row()] == :tool_second[row()-1]),0

)

)

);

show(current data table());

/* try to output the value of the last two columns */

for (i=1, i<n_row, i++, row()=i; show(i, row(),:inspect_pt*,:tool_Change ););*

The result table is OK but the last line of the script did not return any result on the two newly created columns. The log window showed the index becomes ::i.

Output table:

[Missing image]

But the log window showed the result of the last two columns not pulled correctly. Did I used the wrong indexing? Log window output here:

Current Data Table:DataTable("test1")

i:1

Row:1

:Inspect_pt[::i]:. <-- this is not correct

:tool_Change[::i]:. <-- this is not correct

i:2

Row:2

:Inspect_pt[::i]:.

:tool_Change[::i]:.

i:3

Row:3

:Inspect_pt[::i]:.

:tool_Change[::i]:.

i:4

Row:4

:Inspect_pt[::i]:.

:tool_Change[::i]:.

1 ACCEPTED SOLUTION

Accepted Solutions

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

Solution

Try "flushing" JMP's formula buffer with this statement:

Source_Table << run formulas;

Add this line after your formula definitions.

6 REPLIES

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

Try "flushing" JMP's formula buffer with this statement:

Source_Table << run formulas;

Add this line after your formula definitions.

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

Jul 11, 2011 6:03 AM
(511 views)

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

Jul 11, 2011 6:40 AM
(511 views)

Hi HY,

I'm not sure exactly why you need this statement - I got it from JMP tech support. Perhaps someone from JMP could explain?

Regards,

Peter

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

Jul 11, 2011 11:09 AM
(511 views)

Hi

JMP doesn't finish one "command" before moving on to the next - it reads the 'new column' command and starts executing it, but continues to read and perform the next commands.

What happens here is that the 'New Column' commands are not finished executing (this type of command especially takes some time because the graphics have to be updated), before JMP reads the final line with the 'show' commands, so there are no values in the columns at the time this command is executed.

Either 'flush' the formulas as above or put a 'eval formula' directly into the 'new column' command, e.g.

new column("title", numeric, formula(:X1*:X2), eval formula);

As far as I have understood the two approaches have the same effect.

BR, Marianne

PS: I'm not from JMP

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

Jul 11, 2011 4:42 PM
(511 views)

This becomes particularly important when writing scripts that use values from earlier processes for determining how to proceed (e.g. Select Where( :tool_change == 1) in order to subset). By inserting a 'run formulas' line at the end of a block of code like this, you tell JMP to pause, evaluate all pending formulas, and then proceed with the rest of the script.

I'm not as familiar with the behavior of 'eval formula' (I typically use 'run formulas' - just a matter of habit), so this is speculation, but depending on the specific processes I could see situational differences that would favor 'eval formula' over 'run formulas' (i.e. where you only care about one formula for making a decision, you could instruct only that formula to evaluate, saving the remaining formula evaluations for later). The difference here would really depend on how many formula evaluations you need to do and when you want them to be done.

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

Jul 11, 2011 5:21 PM
(511 views)

Thanks everyone on the valuable information. This forum is great.