cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Theresa_Utlaut
Level II
Let JMP write your script!

JMP writes scripts from generated reports or table manipulations. This feature enables a novice scripter to write scripts in a matter of minutes. While teaching an introductory four-hour JSL (JMP Scripting Language) class, we have seen novice scripters write fairly complex scripts by combining different pieces of code produced by JMP in a script window. Even advanced scripters take advantage of JMP writing their code. It saves them time, ensures that there are no typos, and eliminates the need to search for forgotten syntax.

Capture a JSL Script from a Report

There are numerous ways to capture a script from a JMP report. In addition to capturing the script, you can capture enhancements to the report such as reference lines, changes to the axis scales, inclusions and exclusions of options, and much more. If you click on the top left inverted red triangle in a report window, there is a Script option. If the report produces an analysis using a By Group, then there is also a Script All By-Groups option. The figure below shows the options available under Script. Only the options directly related to scripting are discussed.

 

Capturing ScriptsCapturing Scripts

  

Copy Script — This option copies the script so that it can be pasted into a script window, text file, or any other program that handles text.

Save Script to Data Table — This option saves the script as a table property to the table panel of the data table that generated the report. By default, it gives the table property the name of the platform.

Save Script to Journal — This option creates a link on the current journal, or opens a new journal if one is not open. The link runs a script that reproduces the report.

Save Script to Script Window — This option saves the script for the object to a new script window (if one is not open), or appends it to an open script window.

Save Script to Report — This option writes the script to the top of the report window.

Save Script for All Objects — This option saves the script for all objects in a report to a new script window (if one is not open), or appends it to an open script window. When you save a script for all objects, the Where statement defines what is included in a report. It combines all objects in a single window using the New Window( ) function.

Save Script to Project — This option saves the report window to a JMP project. You can retrieve the script by opening the report window and using one of the other options.

Capture By-Groups Analysis

In addition to the Script option, there might be a Script All By-Groups option. The Script All By-Groups option appears if the report produces a BY-group analysis. The options available in Script All By-Groups are a subset of the options available in Script. The difference between Script and Script All By-Groups is that Script All By-Groups saves the script using the JSL command By, and reproduces the analysis as if you used the By command in a dialog box. With Scriptyou save the script for all objects, a new window is created, and each object is added to the window.

Capture Table Manipulations

At this point, you know how to save a script from a report that JMP generates. Now, you are going to find out about one of the most powerful and essential features in JMP — its ability to easily manipulate data tables.

When a new data table is generated from a Tables command, the new data table has a table property called Source (see figure). The JSL code that generated the new data table from an original table is included in the Source table property. However, there are a few exceptions in which the code is either not captured or not that useful.

 

Source Table PropertySource Table Property

  • If you replace a table as a result of selecting Tables ► Sort, the code is not saved in the Source table property. If you want the code to be saved, do not replace the table when you do the sort. If you do not replace the table, the code is added to the new data table. You can copy and paste the code to another location, and add the option Replace Table.
  • If you select Tables ► Subset, the row numbers of the selected rows are included in the code. Having the row numbers is not very useful unless you want the same row numbers every time the code is run. Keep in mind that if you are writing a flexible script, you must select rows and columns before selecting Tables ► Subset. The commands that select portions of a data table are discussed in detail in Chapter 3, “Modifying and Combining Data Tables.”

The content of this post was taken from our book, JSL Companion: Applications of the JMP Scripting Language, Second Edition, where you will find more techniques and examples of working with the JMP Scripting Language. My co-authors are @gzmorgan0 and @Kevin_Anderson.

Last Modified: Jul 2, 2018 10:09 AM
Comments
GeneratingModes
Level I

If you use the feature "Save Script to Report," how do you delete the script if you do not want it?