You are previewing JMP 13 Scripting Guide.
O'Reilly logo
JMP 13 Scripting Guide

Book Description

JMP 13 Scripting Guide provides details for taking advantage of the powerful JMP Scripting Language (JSL). Learn how to write and debug scripts, manipulate data tables, construct display boxes, create JMP applications, and more.

Table of Contents

  1. Contents
  2. Learn about JMP
    1. Documentation and Additional Resources
    2. Formatting Conventions
    3. JMP Documentation
      1. JMP Documentation Library
      2. JMP Help
    4. Additional Resources for Learning JMP
      1. Tutorials
      2. Sample Data Tables
      3. Learn about Statistical and JSL Terms
      4. Learn JMP Tips and Tricks
      5. Tooltips
      6. JMP User Community
      7. JMPer Cable
      8. JMP Books by Users
      9. The JMP Starter Window
    5. Technical Support
  3. Introduction
    1. Welcome to the JMP Scripting Language
    2. What JSL Can Do for You
    3. Help with Learning JSL
      1. The Scripting Guide
      2. The Scripting Index
      3. Let JMP Teach You JSL
    4. Terminology
    5. Basic JSL Syntax
    6. Book Conventions
  4. Getting Started
    1. Let JMP Write Your Scripts
    2. Capturing a Script for an Analysis Report
    3. Capturing a Script for a Data Table
    4. Capturing a Script to Import a File
    5. Gluing Scripts Together
  5. Scripting Tools
    1. Using the Script Editor, Log Window, Debugger and Profiler
    2. Using the Script Editor
      1. Run a Script
      2. Stop a Script
      3. Edit a Script
      4. Color Coding
      5. Auto Complete Functions
      6. Tooltips
      7. Split a Window
      8. Match Parentheses, Brackets, and Braces
      9. Select a Rectangular Block of Text
      10. Select Fragmented Text
      11. Drag and Drop Text
      12. Find and Replace
      13. Automatic Formatting
      14. Add Code Folding Markers
        1. Add More Folding Keywords
      15. Advanced Options
      16. Set Preferences for the Script Editor
    3. Working with the Log
      1. Show the Log in the Script Window
      2. Save the Log
    4. Debug or Profile Scripts
      1. Debugger and Profiler Window
        1. Using the Execution Buttons
        2. Variable Lists
        3. Debugger Options
      2. Work with Breakpoints
        1. Create a Breakpoint
        2. Delete Breakpoints
        3. Disable and Enable Breakpoints
        4. Specify and Clear Conditional Expressions on Breakpoints
        5. Specify Break Options
        6. Run the Script to the Cursor
        7. Tips for Setting Breakpoints
      3. View Variables
        1. Tips for Managing Variables
      4. Work with Watches
      5. Modify Preferences in Debugger
      6. Persistent Debugger Sessions
      7. Examples of Debugging and Profiling Scripts
        1. Using Breakpoints and Watching Global Variables
        2. Stepping Into, Over, and Out
        3. Watching Variables in Different Scopes and Namespaces
        4. Using the Debugger with Interactive Scripts
        5. Using the JSL Profiler
  6. JSL Building Blocks
    1. Learning the Basics of JSL
    2. JSL Syntax Rules
      1. Value Separators
        1. Commas
        2. Parentheses
        3. Semicolons
        4. Double Quotes
        5. Spaces
      2. Numbers
      3. Names
      4. Comments
    3. Operators
    4. Global and Local Variables
      1. Local Namespaces
      2. Named Namespaces
      3. Show Symbols, Clear Symbols, and Delete Symbols
      4. Lock and Unlock Symbols
      5. Hide a Global Variable
    5. Rules for Name Resolution
      1. Variable Names Used as Arguments
      2. Resolving Unscoped Names
      3. Scoping Operators
        1. Scoped Column Names
        2. Unscoped Column Names
        3. Set the Current Data Table Row
      4. Troubleshooting Variables and Column Names
      5. Troubleshooting Variables and Keywords
      6. Frequently Asked Questions about Name Resolution
    6. Alternatives for Gluing Expressions Together
    7. Iterate
      1. For
      2. While
      3. Summation
      4. Product
      5. Break and Continue
        1. Break
        2. Continue
    8. Conditional Functions
      1. If
      2. Match
      3. Choose
      4. Interpolate
      5. Step
    9. Compare Incomplete or Mismatched Data
      1. Missing Values
    10. Inquiry Functions
      1. General Element Types
      2. Specific Element Types
      3. Object Attributes
      4. Host Information
      5. Version Information
  7. Types of Data
    1. Working with Numbers, Strings, Dates, Currency, and More
    2. Numbers and Strings
      1. Unicode Characters
    3. Path Variables
      1. Create and Customize Path Variables
      2. Relative Paths
      3. File Path Separators
    4. Date-Time Functions and Formats
      1. Date-Time Values
      2. Program with Date-Time Functions
        1. Examples of Common Date-Time Functions
        2. Extract Parts of Dates
        3. Arithmetic on Dates
        4. Time Intervals
        5. Two- and Four-Digit Years
      3. Date-Time Values in Data Tables
        1. Change Date-Time Input and Display Formats
    5. Currency
    6. Hexadecimal and BLOB Functions
    7. Work with Character Functions
      1. Concat
      2. Munger
      3. Repeat
    8. Regular Expressions
      1. Regex
      2. Regex Match
      3. Special Characters in Regular Expressions
      4. Escaped Characters in Regular Expressions
      5. Greedy and Reluctant Regular Expressions
      6. Backreferences and Capturing Groups
      7. Lookaround Assertions
    9. Pattern Matching
      1. Patterns and Case
  8. Data Structures
    1. Working with Collections of Data
    2. Lists
      1. Evaluate Lists
      2. Assignments with Lists
      3. Perform Operations in Lists
      4. Find the Number of Items in a List
      5. Subscripts
      6. Locate Items in a List
      7. List Operators
      8. Iterate through a List
      9. Concatenate Lists
      10. Insert a Nested List in an Existing List
      11. Indexing into a List with Another List
    3. Matrices
      1. Construct Matrices
        1. Construct Matrices from Lists
        2. Construct Matrices from Expressions
      2. Subscripts
        1. Single Element
        2. Matrix or List Subscripts
        3. Single Subscripts
        4. Delete Rows and Columns
        5. Select Whole Rows or Columns
        6. Assignment through Subscripts
        7. Operator Assignment
        8. Ranges of Rows or Columns
      3. Inquiry Functions
      4. Comparisons, Range Checks, and Logical Operators
      5. Numeric Operations
        1. Basic Arithmetic
        2. Numeric (Scalar) Functions on Matrices
      6. Concatenation
      7. Transpose
      8. Indexing into a Matrix or List with Another Matrix or List
      9. Matrices and Data Tables
        1. Move Data into a Matrix from a Data Table
        2. Move Data into a Data Table from a Matrix
        3. Summarize Columns
      10. Matrices and Reports
      11. Loc Functions
        1. Loc()
        2. Loc Nonmissing()
        3. Loc Min() and Loc Max()
        4. Loc Sorted()
      12. Ranking and Sorting
      13. Special Matrices
        1. Construct an Identity Matrix
        2. Construct a Matrix with Specific Values
        3. Create a Diagonal Matrix
        4. Create a Column Vector from Diagonal Elements
        5. Calculate Diagonal Quadratic Forms
        6. Return the Sum of Diagonal Elements
        7. Generate a Row Vector of Integers
        8. Reshape a Matrix
        9. Create Design Matrices
        10. Find the Direct Product
      14. Inverse Matrices and Linear Systems
        1. Inverse or Inv
        2. GInverse
        3. Solve
        4. Sweep
        5. Determinant
      15. Decompositions and Normalizations
        1. Eigenvalues
        2. Cholesky Decomposition
        3. Singular Value Decomposition
        4. Orthonormalization
        5. Orthogonal Polynomials
        6. QR Decomposition
        7. Update Inverse Matrices
      16. Build Your Own Matrix Operators
      17. Statistical Examples
        1. Regression Example
        2. ANOVA Example
    4. Associative Arrays
      1. Create Associative Arrays
      2. Work with Associative Arrays
        1. Find the Number of Keys
        2. Add and Delete Keys and Values
        3. Find Keys or Values in an Associative Array
        4. Iterate through an Associative Array
      3. Applications for Associative Arrays
      4. Associative Arrays in Graph Theory
      5. Associative Arrays in Set Operations
  9. Programming Methods
    1. Complex Scripting Techniques and Additional Functions
    2. Lists and Expressions
      1. Stored expressions
        1. Quoting and unquoting expressions
        2. Quote an expression as a string
        3. Store scripts in global variables
        4. Retrieve a Stored Expression, Not its Result
        5. Making lots of substitutions
        6. Evaluate expressions inside lists
        7. Evaluate expressions inside expressions
        8. Parsing Strings into Expressions, and Vice Versa
        9. Summary
      2. Macros
      3. Manipulating lists
        1. In-place operators
        2. Not in-place operators
        3. Substituting
      4. Manipulating Expressions
        1. Substituting
    3. Advanced Scoping and Namespaces
      1. Names Default To Here
        1. Handling Unqualified Named Variable References
        2. Names Default To Here and Global Variables
        3. Example of Using the Names Default To Here() Function
      2. Scoped Names
        1. Predefined Scopes
        2. Example of Using the Window Scope
        3. Example of Using the Here Scope
      3. Namespaces
        1. User-Defined Namespace Functions
        2. Namespace Messages
        3. Using Namespace References
        4. Namespaces and Included Scripts
        5. Examples of User-Defined Namespaces
      4. Referencing Namespaces and Scopes
      5. Resolving Named Variable References
      6. Best Practices for Advanced Scripting
    4. Advanced Programming Concepts
      1. Throwing and Catching Exceptions
      2. Functions
      3. Recursion
      4. Includes
      5. Loading and Saving Text Files
    5. File and Directory Operations
      1. Select a Directory or File
      2. Get a List of Filenames
    6. Scripting BY Groups
    7. Encrypt and Decrypt Scripts
      1. Encryption and Global Variables
      2. Encrypting Scripts in Data Tables
    8. Additional Numeric Operators
      1. Derivatives
      2. Algebraic Manipulations
      3. Maximize and Minimize
        1. Least Squares Example
    9. Scheduling Actions
    10. Functions that Communicate with Users
      1. Writing to the Log
        1. Show
        2. Print
        3. Write
      2. Send information to the User
        1. Beep
        2. Speak
        3. Caption
        4. StatusMsg
        5. Mail
  10. Data Tables
    1. Working with Data Table Objects
    2. Get Started
    3. Basic Data Table Scripting
      1. Open a Data Table
        1. Test for an Open Data Table
        2. Prompt Users to Open a Data Table
        3. Show Only Specific Columns
      2. Create a New Data Table
      3. Import Data
        1. Import Data from a Text File
        2. Import Data from a Microsoft Excel File
        3. Import SAS Data Sets
        4. Import Web Pages and Remote Files
        5. Import HDF5 Files
        6. Import ESRI Shapefiles
        7. Import a Password-Protected Microsoft Excel 2007 File
        8. Import a Database
      4. Set the Current Data Table
      5. Name a Data Table
      6. Save a Data Table
      7. Hide a Data Table
        1. Invisible Data Tables
        2. Private Data Tables
      8. Print a Data Table
      9. Resize a Data Table
      10. Close a Data Table
      11. Set and Get a Data Table
      12. Perform Actions on All Open Data Tables
      13. Create Journals and Layouts
    4. Advanced Data Table Scripting
      1. Store Summary Statistics in Global Variables
      2. Create a Table of Summary Statistics
      3. Subset a Data Table
        1. Subset Data Using the Data Filter
        2. Define the Context of a Data Filter
      4. Sort a Data Table
      5. Stack Values in a Data Table
      6. Split Values in a Stacked Data Table
      7. Transpose a Data Table
      8. Vertically Concatenate Data Tables
      9. Horizontally Concatenate Data Tables
      10. Virtually Join Data Tables
      11. Replace Data in Data Tables
      12. Create a Table Using Tabulate
      13. Find Missing Data Patterns
      14. Compare Data Tables
      15. Create a Summary Table
      16. Subscribe to a Data Table
      17. Move Data Between Matrices and Data Tables
    5. Columns
      1. Send Messages to Data Column Objects
      2. Create Columns
      3. Add Several Columns at Once
      4. Group Columns
        1. Get Column Groups or Names
        2. Select a Column Group
        3. Rename a Column Group
        4. Move a Column Group
      5. Select Columns
      6. Rearrange and Move Columns
      7. Add a Column Switcher
      8. Compress Selected Columns
      9. Delete Columns
      10. Obtain Column Names
      11. Column Attributes
        1. Set or Get a Column Name
        2. Set or Get Column Values
        3. Set or Get Value Labels
        4. Set or Get Data and Modeling Types
        5. Set or Get Formats
        6. Set, Get, or Evaluate a Formula
        7. Set and Get Range and List Checks
        8. Get a Column Script
        9. Preselect Roles
        10. Lock a Column
      12. Column Properties
    6. Rows
      1. Add Rows
      2. Delete Rows
      3. Select Rows
      4. Find Rows
      5. Move Rows
      6. Assign Colors and Markers to Rows
      7. Color Cells
      8. Hide, Exclude, and Label Rows
      9. Iterate on Rows in a Table
        1. Set the Current Row
        2. What is the Current Row?
        3. How Many Rows and Columns?
        4. Iterate a Script on Each Row
        5. Return Row Values
        6. Add Sequence Data
      10. Row States and Operators
        1. About Row States
        2. About Row State Operators
        3. Assign Row States
        4. Store Row State Information
        5. Set or Get Row States
        6. Identify Row State Changes
        7. Exclude, Hide, Label, and Select
        8. Colors and Markers
        9. The Numbers behind Row States
    7. Accessing Data Values
      1. Set or Get Values by Column Name
      2. Additional Ways to Access Data Values
    8. Add Metadata to a Data Table
      1. Table Variables
      2. Table Scripts
      3. Formulas
      4. Delete Metadata
    9. Calculations
      1. Pre-Evaluated Statistics
        1. Columnwise Functions
        2. Rowwise Functions
      2. Calculator Formulas
  11. Scripting Platforms
    1. Create, Repeat, and Modify Analyses
    2. Example of Scripting a Platform
    3. Send Messages to a Platform
      1. Conventions for Messages and Arguments
      2. Send Multiple Messages
      3. Find Messages for Objects
      4. Interpret the Show Properties List
    4. Specify Which Columns to Analyze
      1. Create Column References
      2. Specify Multiple Column Names at Once
      3. Enable Users to Specify Columns
      4. Specify a By Variable
    5. Filter by Value or Column
    6. Enable User Input
    7. Execute Embedded Red Triangle Options
    8. Make Platforms Invisible
    9. Specify Report Titles
    10. Common Messages for Platform Windows
    11. Scripting Considerations by Platform
      1. Categorical
        1. Scripting for Supercategories
      2. Control Charts
        1. Customize Tests in Control Chart Builder
        2. Run Alarm Scripts
        3. Set Phase Limits
      3. Distribution
      4. DOE
        1. Global Variables
      5. Fit Model
        1. Fit Group
        2. Effects
        3. Send Function
        4. Standard Least Squares
      6. Neural and Neural Net
      7. Partial Least Squares and PLS
      8. Process Capability
        1. Specification Limits in JSL Scripts
        2. Using a Limits Data Table and JSL
      9. Scatterplot 3D
      10. Explorer Outliers
    12. Scripting-Only Messages and Arguments by Platform
      1. Bivariate
      2. Choice
      3. Clustering
      4. Control Chart
      5. Cumulative Damage
      6. Custom Profiler
      7. Distribution
      8. Fit Life by X
      9. Fit Model
      10. Fit Parametric Survival
      11. Life Distribution
      12. Multivariate
      13. Neural
      14. Pareto Plot
      15. Partition
      16. Surface Plot
      17. Text Explorer
      18. Time Series
      19. Variability
  12. Display Trees
    1. Create and Interact with Windows
    2. Navigate JMP Reports
      1. Compatibility Warning
      2. Examples of Common Display Boxes
      3. View the Display Tree
      4. Show Display Box Properties
      5. Display Box Object References
        1. Learning What You Can Do with a Display Box
        2. Create a Reference By Subscripting
      6. Send Messages to Display Boxes
        1. The << Operator
        2. Nesting and Precedence
        3. Customize Reports with the Send to Report and Dispatch Functions
        4. Create a Journal
        5. Using Common Messages
      7. Example of Creating a Report
    3. Construct Custom Windows
      1. Example of Creating a Graph Box
      2. Extract Values from a Window
        1. Extract Values: Method One
        2. Extract Values: Method Two
        3. Extract Values: Method Three
      3. Constructors for New Windows
        1. Container Display Boxes
        2. Display Element Boxes
        3. Input Selector Display Boxes
        4. Filtering Display Boxes
        5. Examples of Combined Display Boxes
        6. Example of Slider Boxes and Range Slider Boxes
        7. Example of a Calendar and Date Selector
        8. Example of Constructing a Summary Results Report
      4. Interact with a Closing Window
      5. Update an Existing Display
        1. Append
        2. Prepend
        3. Delete
        4. Sib Append
      6. Set Function and Set Script
      7. Get and Set Selected Values of Display Elements That Return Lists
      8. Send Messages to Constructed Displays
      9. Construct Display Boxes That Contain Platforms
      10. Examples of Creating a Dashboard from Two Reports
        1. Dashboard with One Row of Reports
        2. Dashboard with Tabs
        3. How to Dock Tabs in Tab Boxes
      11. Example of Creating a Cluster Platform Launch Window
      12. Example of Constructing a Custom Platform
    4. Modal Windows
      1. Construct a Modal Window
      2. Construct a Column Dialog
      3. Comparison of Column Dialog and New Window
      4. Constructors for Column Dialogs
    5. Script Editor Commands
    6. Convert Deprecated Dialog to New Window
      1. Comparison of New Window and the Deprecated Dialog
        1. New Window Example
        2. Example of Deprecated Dialog
      2. Differences Between New Window and the Deprecated Dialog
        1. Strings and Lists
        2. List Boxes and Check Boxes
        3. Line Up Items
        4. Radio Boxes
        5. Text Edit Boxes
        6. Number Edit Boxes
      3. Optional Scripts in New Window
    7. Technical Details
      1. Writing Tab Box and Tab Page Box Scripts
  13. Scripting Graphs
    1. Editing and Creating Two-Dimensional Graphs
    2. Adding Scripts to Graphs
      1. Specify the Order of Graphical Elements
        1. Copy and Paste Frame Contents or Settings
    3. Create New Graphs from Scratch
      1. Customize Graphs
    4. Graph Elements
      1. Plot Functions
        1. Gradient Function
      2. Get the Properties of a Graphics Frame
      3. Add a Legend
    5. Add Lines, Arrows, Points, Shapes, and Text
      1. Draw Lines
      2. Draw Arrows
      3. Draw Markers
      4. Draw Pies and Arcs
      5. Draw Regular Shapes: Circles, Rectangles, and Ovals
        1. Circles
        2. Rectangles
        3. Ovals
      6. Draw Irregular Shapes: Polygons and Contours
        1. Polygons
        2. Contours
      7. Add Text
      8. Specify Colors
      9. Specify Transparency
      10. Add Fill Patterns
      11. Specify Line Types
      12. Draw with Pixels
    6. Interactive Graphs
      1. Handle()
      2. Mousetrap()
      3. Drag Functions
      4. Troubleshoot Interactive Graphs
    7. Create Background Maps
  14. Three-Dimensional Scenes
    1. Scripting in Three Dimensions
    2. About JSL 3-D Scenes
    3. JSL 3-D Scene Boxes
    4. Setting the Viewing Space
      1. Setting Up a Perspective Scene
      2. Setting up an Orthographic Scene
    5. Changing the View
      1. The Translate Command
      2. The Rotate Command
      3. The Look At Command
      4. The ArcBall
    6. Graphics Primitives
      1. Primitives Example
      2. Controlling the Appearance of Primitives
        1. Size and Width
        2. Stippling Pattern
        3. Fill Pattern
      3. Other uses of Begin and End
    7. Drawing Spheres, Cylinders, and Disks
      1. Construction
        1. Cylinders
        2. Disks
        3. Spheres
      2. Lighting
    8. Drawing Text
      1. Using Text with Rotate and Translate
    9. Using the Matrix Stack
    10. Lighting and Normals
      1. Creating Light Sources
      2. Lighting Models
      3. Normal Vectors
      4. Shading Model
      5. Material Properties
      6. Alpha Blending
      7. Fog
      8. Example
    11. B├ęzier Curves
      1. One-Dimensional Evaluators
      2. Two-Dimensional Evaluators
    12. Using the Mouse
      1. Pick Commands
    13. Arguments
  15. Extending JMP
    1. External Data Sources, Analytical Tools, and Automation
    2. Real-Time Data Capture
      1. Create a Datafeed Object
        1. Datafeed Options
      2. Read in Real-Time Data
      3. Manage a Datafeed with Messages
      4. Examples of Datafeed
        1. Reading Data
        2. Set Up a Live Control Chart
        3. Store the Script in a Data Table
    3. Dynamic Link Libraries (DLLs)
    4. Using Sockets in JSL
      1. Socket-Related Commands
      2. Messages for Sockets
    5. Database Access
      1. Creating a Database Connection and Executing SQL
    6. Writing a SQL Query
    7. Working with SAS
      1. Make a SAS DATA Step
      2. Create SAS DATA Step Code for Formula Columns
      3. SAS Variable Names
      4. Get the Values of SAS Macro Variables
      5. Connect to a SAS Metadata Server
        1. Make the Connection
        2. Automatically Connect SAS Libraries
        3. View SAS Libraries
        4. Open SAS Data Sets
        5. Save SAS Data Sets
        6. Run a Stored Process
        7. Submit SAS Code from JMP
      6. Preferences
      7. Sample Scripts
    8. Working with MATLAB
      1. Installing MATLAB
        1. How JMP Finds MATLAB
        2. Test Your Install
    9. Working with R
      1. Installing R
        1. Override Default R Install Location
        2. How JMP Finds R
        3. Testing Your Setup
      2. JMP to R Interfaces
      3. R JSL Scriptable Object Interfaces
      4. Conversion Between JMP Data Types and R Data Types
        1. JMP Scoping Operators and R
        2. Using R Name() with R Send()
      5. Troubleshooting
        1. Recording Output
        2. Character Vectors
        3. Element Names
      6. Examples
        1. Sending a Data Table to R
        2. Creating Objects in R
        3. Using R Functions and Graphics
        4. Simple Matrix Addition in R
        5. A Bootstrap Sample
    10. Working with Microsoft Excel
    11. Parsing XML
    12. OLE Automation
  16. Creating Applications
    1. Application Builder
    2. Create Applications with Application Builder
      1. Example of Creating an Application
      2. Application Builder Terminology
      3. Design an Application
      4. Application Builder Window
      5. Application Builder Red Triangle Options
      6. Create an Application
        1. Create a New Application
        2. Manage Modules
        3. Modal Dialog Modules
        4. Arrange and Remove Objects
        5. Customize Object Properties
        6. Write Scripts
      7. Edit or Run an Application
      8. Options for Saving Applications
      9. Additional Examples of Creating Applications
        1. Parameterizing Variables
        2. Filtering Data in Multiple Reports
        3. Selecting Dates
    3. Compile Add-Ins with the JMP Add-In Builder
      1. Compile Scripts into an Add-In Using Add-In Builder
      2. Edit an Add-In
      3. Share an Add-In
      4. Installing Multiple Add-Ins
      5. Register an Add-In Using JSL
      6. Create an Add-In Manually
        1. Example of a addin.def File
        2. Example of a JMP Add-In
      7. Manage JMP Add-Ins
        1. Install Add-Ins
        2. View Your Add-Ins
        3. Update Add-Ins
        4. Disable, Enable, and Remove Add-Ins
  17. Common Tasks
    1. Getting Started with Sample Scripts
    2. Run a Script at Start Up
    3. Convert Character Dates to Numeric Dates
    4. Format Date/Time Values and Subset Data
    5. Create a Formula Column
    6. Extract Values from an Analysis into a Report
    7. Create an Interactive Program
  18. Compatibility Notes
    1. Changes in Scripting from JMP 12 to JMP 13
    2. Compatibility Issues
    3. Deprecated JSL
  19. Glossary
    1. Terms, Concepts, and Placeholders
  20. Index
    1. Scripting Guide
    2. Symbols
    3. A
    4. B
    5. C
    6. D
    7. E
    8. F
    9. G
    10. H
    11. I
    12. J
    13. L
    14. M
    15. N
    16. O
    17. P
    18. Q
    19. R
    20. S
    21. T
    22. U
    23. V
    24. W-Z