All rights reserved. Produced in the United States of America.
For a hard-copy book: No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, photocopying, or otherwise, without
the prior written permission of the publisher, SAS Institute Inc.
For a Web download or e-book: Your use of this publication shall be governed by the terms established
by the vendor at the time you acquire this publication.
U.S. Government Restricted Rights Notice: Use, duplication, or disclosure of this software and related
documentation by the U.S. government is subject to the Agreement with SAS Institute and the
restrictions set forth in FAR 52.227-19, Commercial Computer Software-Restricted Rights (June 1987).
SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.
1st printing, September 2010
2nd printing, January 2011
®
JMP
, SAS® and all other SAS Institute Inc. product or service names are registered trademarks or
trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.
Other brand and product names are registered trademarks or trademarks of their respective companies.
Get the Most from JMP
Whether you are a first-time or a long-time user, there is always something to learn about JMP.
Visit JMP.com to find the following:
•live and recorded Webcasts about how to get started with JMP
•video demos and Webcasts of new features and advanced techniques
•schedules for seminars being held in your area
•success stories showing how others use JMP
•a blog with tips, tricks, and stories from JMP staff
JMP was developed by SAS Institute Inc., Cary, NC. JMP is not a part of the SAS System, though portions
of JMP were adapted from routines in the SAS System, particularly for linear algebra and probability
calculations. Version 1 of JMP went into production in October 1989.
Credits
JMP was conceived and started by John Sall. Design and development were done by John Sall, Chung-Wei
Ng, Michael Hecht, Richard Potter, Brian Corcoran, Annie Dudley Zangi, Bradley Jones, Craige Hales,
Chris Gotwalt, Paul Nelson, Xan Gregg, Jianfeng Ding, Eric Hill, John Schroedl, Laura Lancaster, Scott
McQuiggan, Melinda Thielbar, Clay Barker, Peng Liu, Dave Barbour, Jeff Polzin, John Ponte, and Steve
Amerige.
In the SAS Institute Technical Support division, Duane Hayes, Wendy Murphrey, Rosemary Lucas, Win
LeDinh, Bobby Riggs, Glen Grimme, Sue Walsh, Mike Stockstill, Kathleen Kiernan, and Liz Edwards
provide technical support.
Nicole Jones, Kyoko Keener, Hui Di, Joseph Morgan, Wenjun Bao, Fang Chen, Susan Shao, Michael
Crotty, Jong-Seok Lee, Tonya Mauldin, Audrey Ventura, Ani Eloyan, Bo Meng, and Sequola McNeill
provide ongoing quality assurance. Additional testing and technical support are provided by Noriki Inoue,
Kyoko Takenaka, Yusuke Ono, Masakazu Okada, and Naohiro Masukawa from SAS Japan.
Bob Hickey and Jim Borek are the release engineers.
The JMP books were written by Ann Lehman, Lee Creighton, John Sall, Bradley Jones, Erin Vang, Melanie
Drake, Meredith Blackwelder, Diane Perhac, Jonathan Gatlin, Susan Conaghan, and Sheila Loring, with
contributions from Annie Dudley Zangi and Brian Corcoran. Creative services and production was done by
SAS Publications. Melanie Drake implemented the Help system.
Jon Weisz and Jeff Perkinson provided project management. Also thanks to Lou Valente, Ian Cox, Mark
Bailey, and Malcolm Moore for technical advice.
Thanks also to Georges Guirguis, Warren Sarle, Gordon Johnston, Duane Hayes, Russell Wolfinger,
Randall Tobias, Robert N. Rodriguez, Ying So, Warren Kuhfeld, George MacKensie, Bob Lucas, Warren
Kuhfeld, Mike Leonard, and Padraic Neville for statistical R&D support. Thanks are also due to Doug
Melzer, Bryan Wolfe, Vincent DelGobbo, Biff Beers, Russell Gonsalves, Mitchel Soltys, Dave Mackie, and
Stephanie Smith, who helped us get started with SAS Foundation Services from JMP.
Acknowledgments
We owe special gratitude to the people that encouraged us to start JMP, to the alpha and beta testers of JMP,
and to the reviewers of the documentation. In particular we thank Michael Benson, Howard Yetter (d),
xviii
Andy Mauromoustakos, Al Best, Stan Young, Robert Muenchen, Lenore Herzenberg, Ramon Leon, Tom
Lange, Homer Hegedus, Skip Weed, Michael Emptage, Pat Spagan, Paul Wenz, Mike Bowen, Lori Gates,
Georgia Morgan, David Tanaka, Zoe Jewell, Sky Alibhai, David Coleman, Linda Blazek, Michael Friendly,
Joe Hockman, Frank Shen, J.H. Goodman, David Iklé, Barry Hembree, Dan Obermiller, Jeff Sweeney,
Lynn Vanatta, and Kris Ghosh.
Also, we thank Dick DeVeaux, Gray McQuarrie, Robert Stine, George Fraction, Avigdor Cahaner, José
Ramirez, Gudmunder Axelsson, Al Fulmer, Cary Tuckfield, Ron Thisted, Nancy McDermott, Veronica
Czitrom, Tom Johnson, Cy Wegman, Paul Dwyer, DaRon Huffaker, Kevin Norwood, Mike Thompson,
Jack Reese, Francois Mainville, and John Wass.
We also thank the following individuals for expert advice in their statistical specialties: R. Hocking and P.
Spector for advice on effective hypotheses; Robert Mee for screening design generators; Roselinde Kessels
for advice on choice experiments; Greg Piepel, Peter Goos, J. Stuart Hunter, Dennis Lin, Doug
Montgomery, and Chris Nachtsheim for advice on design of experiments; Jason Hsu for advice on multiple
comparisons methods (not all of which we were able to incorporate in JMP); Ralph O’Brien for advice on
homogeneity of variance tests; Ralph O’Brien and S. Paul Wright for advice on statistical power; Keith
Muller for advice in multivariate methods, Harry Martz, Wayne Nelson, Ramon Leon, Dave Trindade, Paul
Tobias, and William Q. Meeker for advice on reliability plots; Lijian Yang and J.S. Marron for bivariate
smoothing design; George Milliken and Yurii Bulavski for development of mixed models; Will Potts and
Cathy Maahs-Fladung for data mining; Clay Thompson for advice on contour plotting algorithms; and
Tom Little, Damon Stoddard, Blanton Godfrey, Tim Clapp, and Joe Ficalora for advice in the area of Six
Sigma; and Josef Schmee and Alan Bowman for advice on simulation and tolerance design.
For sample data, thanks to Patrice Strahle for Pareto examples, the Texas air control board for the pollution
data, and David Coleman for the pollen (eureka) data.
Translations
Trish O'Grady coordinates localization. Special thanks to Noriki Inoue, Kyoko Takenaka, Masakazu Okada,
Naohiro Masukawa, and Yusuke Ono (SAS Japan); and Professor Toshiro Haga (retired, Tokyo University
of Science) and Professor Hirohiko Asano (Tokyo Metropolitan University) for reviewing our Japanese
translation; François Bergeret for reviewing the French translation; Bertram Schäfer and David Meintrup
(consultants, StatCon) for reviewing the German translation; Patrizia Omodei, Maria Scaccabarozzi, and
Letizia Bazzani (SAS Italy) for reviewing the Italian translation; RuiQi Qiao, Rula Li, and Molly Li for
reviewing Simplified Chinese translation (SAS R&D Beijing); Finally, thanks to all the members of our
outstanding translation and engineering teams.
Past Support
Many people were important in the evolution of JMP. Special thanks to David DeLong, Mary Cole, Kristin
Nauta, Aaron Walker, Ike Walker, Eric Gjertsen, Dave Tilley, Ruth Lee, Annette Sanders, Tim Christensen,
Eric Wasserman, Charles Soper, Wenjie Bao, and Junji Kishimoto. Thanks to SAS Institute quality
assurance by Jeanne Martin, Fouad Younan, and Frank Lassiter. Additional testing for Versions 3 and 4 was
done by Li Yang, Brenda Sun, Katrina Hauser, and Andrea Ritter.
Also thanks to Jenny Kendall, John Hansen, Eddie Routten, David Schlotzhauer, and James Mulherin.
Thanks to Steve Shack, Greg Weier, and Maura Stokes for testing JMP Version 1.
Thanks for support from Charles Shipp, Harold Gugel (d), Jim Winters, Matthew Lay, Tim Rey, Rubin
Gabriel, Brian Ruff, William Lisowski, David Morganstein, Tom Esposito, Susan West, Chris Fehily, Dan
Chilko, Jim Shook, Ken Bodner, Rick Blahunka, Dana C. Aultman, and William Fehlner.
Technology License Notices
xix
Scintilla is Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>.
This introduction shows you the basics of JMP Scripting Language (JSL). The chapter starts with a simple,
progressive tutorial example to show you where to type a script, how to submit it, and how to modify and
save it. The purpose of this tutorial is to give you the basic techniques for working with any script, whether
it’s one you write or one you get from someone else. Next is a showcase of examples to demonstrate how
scripting might be useful in a variety of settings. For example, classroom simulations, advanced data
manipulations, custom statistics, production lines, and so forth.
Confusion alert! Throughout this book, special shaded “confusion alerts” like this one
call your attention to important concepts that could be unfamiliar or more
complicated than you might expect, or where JMP might be a little different from
other applications. These alerts appear whenever a particularly good example of a
potential problem arises in the text, and although you will find them under topics that
might not apply to your immediate needs, the ideas presented are always general and
important. Please be sure to take a look even when you are skipping pages and looking
for something else.
You can quickly locate these pointers by looking up “confusion alert” in the “Index,”
p. 713.
This exercise is simple and hearkens back to a classic. Perhaps you recognize it.
1. Start JMP.
2. If the log window is not open, open it by selecting
Macintosh.
3. In the JMP Starter window, click
New Script.
New scripts can also be created from the menus. On Windows, select
Macintosh, select
File>New>NewScript.
4. In the resulting script editor, type these lines:
A = "Hello, World";
Show( A );
5. From the Edit menu, select Run Script.
The keyboard shortcut is to press CTRL-R on Windows or COMMAND-R on Macintosh.
The result is shown in the Log window. Besides showing results and errors, this window is also a script
editor.
View > Log on Windows or Window > Log on
File > New > Script. On
Figure 1.1 The Script Window (left) and the Log Window (right)
This is how you enter and submit JSL. You have just created a global variable named A, assigned a value to
it, and shown its value. Notice that the log echoes your script first, and then echoes any results. In this case,
the result is the output for the
Show(A) command.
Go To Line
As your scripts grow in size, it is handy to jump to specific lines in the script. Use the
from the
Edit menu to jump to a specific line.
Go To Line command
4Introducing JSLChapter 1
Hello, World
This command is also useful during the debugging process, since error messages frequently mention the line
of the script where the error occurred.
Show Line Numbers
The script window does not show line numbers by default. To see the line numbers, right-click anywhere in
the script window, and then select
Show Line Numbers.
Modify the Script
Now try making this script do a little more work by adding a For-loop to greet the world not just once, but
four times. Also, use
For-loop works.
1. In the script window, change the script to this:
For( i = 1, i < 5, i++,
X = i;
A = "Hello, World";
Print( X, A );
);
Print( "done" );
2. Submit the script as before.
(To submit part of the text in a window instead of all text, select the text first and then press Control-R
on Windows or a-R on Macintosh)
Print this time instead of Show, and make a few other changes to see how the
Output
1
"Hello, World"
2
"Hello, World"
3
"Hello, World"
4
"Hello, World"
"done"
Print
is similar to Show except that it does not label the results with the variable name. It just prints the
value.
Stopping a Script
When you run a script, the
is running, you can select this option to stop it. You can also press ESC on Windows or
COMAND-PERIOD on Macintosh . Many scripts execute more quickly than you can stop them.
Run Script command in the Edit menu changes to Stop Script. While a script
Chapter 1Introducing JSL5
Hello, World
Punctuation and Spaces
Notice the indented lines inside the
For-loop. This is not necessary for JMP’s sake; it just makes it a little
easier to read. You could write this script like this if you want:
fo R(i=
1,i<5,i++
,X=i;A="Hello, World";P r i N T(X,A));print("done");
Words in JMP’s scripting language are separated by parentheses, commas, semicolons, and various operators
such as +, –, and so on. As far as JMP is concerned, spaces, tabs, returns, and blank lines inside or between
operators or within JSL words do not exist. This is because most JSL words come from JMP’s usual
graphical user interface (GUI), and most of those commands have spaces in them. For example, you will see
later on that to do Fit Model, the JSL would be
parentheses)
. Most people would rather see “Fit Model” than “fitmodel.”
Fit Model(and some arguments inside
JSL is not case-sensitive, so you do not have to worry about reaching for the Shift key all the time.
You do have to be a little careful inside a text string. In “Hello, World” extra spaces would affect the output,
because text strings inside double quotation marks are taken literally, exactly as you type them. Also, you
would get errors if you put spaces between the two plus signs in
same as
43).
i++, (i+ +), or in numbers (43 is not the
Generally, JSL uses:
commas , between arguments inside the parentheses for a command.
parentheses ( ) to surround all the arguments of a command. Many JSL words have parentheses after
them even if they do not take arguments; for example
the number 3.14...
do give it. Therefore,
Pi does not expect an argument and will complain about any argument that you
Pi(mincemeat) would be considered an error (although it seems heretical to
pi() has the parentheses even though π is just
say so). But the parentheses are still required.
semicolons ; to separate commands but also to glue them together. In other words, you use a
semicolon to separate one complete message from the next. For example,
semicolon really does is tell JMP to continue and do more things. For example, the
a=1;b=2. What the
For-loop
example showed how to put several statements in the place of one statement for the fourth
argument, because the semicolon effectively turned all three statements into one argument.
Trailing semicolons (extras at the end of a script or at the end of a list of arguments) are harmless, so
you can also think of semicolons as terminating characters. In fact, terminating each complete JSL
statement with a semicolon is a good habit to adopt.
quotation marks " " to enclose text strings. Anything inside quotation marks is taken literally,
exactly as is, including spaces and upper- or lower-case. Nothing that could be evaluated is evaluated.
If you have
pi()^2 inside quotation marks, it is just a sequence of six characters, not a value close to
ten. See “Quoted Strings,” p. 28, for ways to include special characters and quotation marks in
strings.
For a more formal discussion of punctuation rules, see “Lexical Rules of the Language,” p. 26.
6Introducing JSLChapter 1
Saving and Sharing Your Work
Save a Script
To save your script, just follow these instructions:
1. Make the script window active (click the “Untitled” window to make it the front-most window).
2. From the
3. Specify a filename, including the extension
4. Click
Scripts are saved as text files, and you can edit them with any text editor. However, if you do edit scripts
with applications other than JMP, be careful to save them as plain text files. If you preserve the
you can double-click a script file to launch JMP.
File menu, select Save or Save As.
.jsl. For example, hello.jsl.
Save.
.jsl extension,
To reuse a script, use
Open from JMP’s File menu, double-click a .jsl file, or drag and drop the file onto
JMP’s application icon.
When opening a JSL file, the actual script is always opened in its own script window. However, it might be
distracting to some users to see this window. To keep a script from opening in a script window, put this
command on the first line of the script.
//!
If it is not on the very first line by itself, this command does nothing.
You can over-ride this comment when opening the file. Select
select the JSL file and click
Open. The script opens into a script window instead of being executed.
Save the Log
You can also save logs as text files, which can be viewed with any text editor. Double-clicking a log file does
not launch JMP.
1. Make the log window active (click the Log window to make it the front-most window).
2. From the
File menu, select Save or Save As.
3. Specify a filename, including the extension .txt on Windows. For example, hello.txt.
4. Click Save
Saving and Sharing Your Work
File > Open. Hold the CTRL key while you
Here is something just about everybody will find useful sooner or later: JMP can create scripts to duplicate
your data tables and analyses. For example:
•Suppose you need to describe an analysis process in detail, from beginning to end, such as to create an
audit trail for a governing agency or for peers reviewing your journal article.
•Suppose you have a set of analysis steps that should be followed routinely by your lab technicians.
•Suppose you fit the same model to new data every day, and you are tired of clicking the same buttons
over and over again.
Chapter 1Introducing JSL7
Saving and Sharing Your Work
•Suppose you are working with somebody in another city who cannot simply look over your shoulder to
see how you put something together.
You can use JMP interactively as usual, save scripts to reproduce your work, and in the future just run those
scripts. Next are some examples showing how this works.
Capturing Scripts for Data Tables
1. Open a data table and make all types of changes. For example, add rows and columns, change values,
rearrange columns, sort the rows, make a formula column, make a row state column, and so on.
2. When you are finished, open a script window and type this:
current data table()<<get script;
3. In the Script window, click and drag to select (highlight) the script.
4. Run the script and look at the output shown in the Log window:
From the
Figure 1.2 The Get Script Command and the Log
Edit menu, select Run Script.
Now try running the script in the log window:
1. In the Log window, click and drag to select (highlight) the script, starting with
with the last line in the log.
2. From the
Edit menu, select Run Script.
New Table and ending
8Introducing JSLChapter 1
Saving and Sharing Your Work
The script produces a perfect clone of your data table.
Capturing Scripts for Analyses
Launch a platform, such as Fit Model. Look at the default results and then go exploring. Try options to see
related tests and graphs. Work with the red triangle menus in the report surface to get exactly the report that
you want.
When you are finished, get a script to recreate your results. There are two methods of getting a script for
your results. One is to use the Script menu located at the bottom of each platform’s red triangle menu. This
method is detailed in “Use JMP Interactively to Learn Scripting,” p. 11.
1. First you need to figure out what JMP calls your analysis. This can be tricky in some cases, as discussed
in the “Scripting Platforms” chapter, but usually you can read it from the title of the analysis window,
after the name of the data table. For example, the platform for a window titled “Big Class: Fit Least
Squares” would be called
2. Now you have to specify a part of the report. You might have fit several models before getting the one
that you want to keep. You need to tell JMP which one you want by supplying a subscript, which is just
a number inside brackets after the name. If the third model that you fit is the one that you want, you
would specify it as
3. You are ready to get the script from the object:
Fit Least Squares[3] << get script;
Fit Least Squares.
Fit Least Squares[3].
The results might look something like this, depending on which steps you performed:
Fit Model(
Y( :weight ),
Effects( :sex, :height, :sex * :height ),
Personality( Standard Least Squares ),
Run Model(
Profiler(
Confidence Intervals( 1 ),
Desirability Functions( 1 )
),
Contour Profiler(
Surface Plot( 1 )
)
)
)
Tr y r un ni n g th e s c ri p t:
1. In the Log window, click and drag to select (highlight) the script
2. From the
Edit menu, select Run Script.
The script produces a perfect clone of your analysis. If you want a journal, use this command:
Fit Least Squares[1] << journal window;
Chapter 1Introducing JSL9
Saving and Sharing Your Work
A General Method for Creating Scripts
1. Did you use an existing data table as is? Write an Open statement for it:
dt = Open( "$SAMPLE_DATA/Big Class.JMP" );
2. Did you create a new table or make changes to an existing data table? Did you work with row states,
such as to color and label points in your plots? Did you exclude some rows? Did you fix errors? If so, you
should get a script to recreate your data table.
Current Data Table() << get script;
3. Which platforms did you launch, work with, and keep for your final results? Get scripts to recreate
them. You will learn the details in the “Scripting Platforms” chapter; here you will just try some
examples.
Bivariate[1] << get script;
Fit Least Squares[1] << get script;
4. Now edit the log into a complete script. Be sure to put semicolons ( ; ) in between statements. You
might have something like this:
New Table( "Big Class",
Add Rows( 40 ),
New Column( "name",
Character,
Nominal,
Set Property( Notes, "...usually used as a label variable in plots" ),
Values(