Use the Open() function to open a data table.
The path to the data table can be a quoted literal path (absolute or relative) or an unquoted expression that yields a pathname. Relative paths are interpreted relative to the location of the .jsl file (for a saved script). For unsaved scripts, the path is relative to your primary partition (Windows) or your <username>/Documents folder (Macintosh).
JMP provides shortcuts (path variables) to directories or files. Instead of entering the entire path to the directory or file, you include a path variable in the Open() expression. For example, JMP sample scripts typically use the $SAMPLE_DATA path variable to open files in the Samples/Data folder. For details about path variables, see Path Variables in Types of Data.
In a script that depends on an opened data table, you can test to see whether the table is open using Is Empty() or Is Scriptable(). In the following example, the script performs a Bivariate analysis on Big Class.jmp and then closes the data table. Before proceeding to the Oneway analysis later in the script, Is Scriptable() tests for the open data table. If 1 (true) is returned, the table opens, and the script continues.
You can use an If() expression to prompt a user to open a data table, if no open data table is found. And if they do not select a table, the script should end. The following script shows an example:
The user is prompted to open a data table. If the user clicks Cancel instead of opening a data table, an error appears in the log.
To open a data table and show only a specific set of columns, identify those columns in the Open() expression. This is particularly helpful with a large data table in which only a few columns are necessary.
The following example opens Big Class.jmp and includes only the age, height, and weight columns.
An optional argument that can define the new table. For example, the following script creates a new data table named Little Class. It adds three rows and two named columns as well as entering values for each cell in the table:
The following Open() options are available:
Columns(colName=colType(colWidth),... )
// colType is Character|Numeric
// colWidth is an integer specifying the width of the column
Identifies column names, column types, and column widths with a Columns argument as shown in the preceding examples.
If you specify settings for a column other than the first column in the file, you must also specify settings for all the columns that precede it. Suppose that you want to open a text file that has four columns (name, sex, and age, and ID, in that order). age is a numeric column, and the width should be 5. You must also set the name and sex column types and widths, and list them in the same order:
John Doe is interpreted as two separate strings (John and Doe).
"John Doe" is interpreted as a single string. Most programs (including JMP) read a quotation mark and ignore other field delimiters until the second quotation occurs.
If you include Strip Quotes(1), "John Doe" is interpreted as John Doe (one string without quotation marks).
Use the Other option to use an additional character for the row separator, which you must specify in the EOLOther argument. JMP interprets either this character or the default character as a row separator.
Use the Other option to use a different character for the field separator, which you must specify in the EOFOther argument.
The Space option uses a single space as a delimiter.
The Spaces option uses two or more spaces.
Specifies the character or characters used to separate fields or rows. For example, EOLOther("*") indicates that an asterisk separates rows in the text file.
When you open a Microsoft Excel workbook in JMP, the file is converted to a data table. JMP supports .xls, .xlsm, and .xlsx formats. See the Using JMP book for details about Microsoft Excel support.
Excel Open Method specifies how an Excel file should be opened by default, when using a non-specific open statement.
Use Excel Wizard opens the Excel Import Wizard to import the file. This is the default setting.
Open All Sheets opens all worksheets in the Excel file.
Select Individual Worksheets prompts users to select one or more worksheets when they open the file.
Use Excel Labels as Headings determines whether text in the first row of the spreadsheet is converted to column headings in the data table.
Suppose that you want to import data from specific worksheets in your workbook. Specify those worksheets using the Worksheets argument. In the following example, the worksheet named small is imported into JMP.
.xpt and .stx file formats are also supported.
In the Open() command, specify the quoted URL to open a file from a website. You can open JMP data tables or other supported file types this way.
n identifies which table you want to import. For example, to import the fourth table on the page, specify HTML Table(4). If you omit the value, only the first table on the page is imported.
An ESRI shapefile is a geospatial vector data format used to create maps. JMP imports shapefiles as data tables. A .shp shapefile consists of coordinates for each shape. A .dbf shapefile includes values that refer to regions. To create maps in JMP, you modify the structure of the data and save the files with specific suffixes.
The following example imports a .shp file and saves it with the -XY suffix.
Save the .dbf file with the -Name suffix.
JMP does not support importing password-protected .xlsx files. Import password-protected Excel 2007 .xls files by including the Password argument.
Note: Password-protected Excel version 2010 and 2013 .xlsx files are not supported even if you save the file as .xls.
Open Database() opens a database using Open Database Connectivity (ODBC) and extracts data into a JMP data table. See the Database Access in Extending JMP for more information.
JMP also converts DataBase Files (.dbf) files to data table format.
Current Data Table() can also take a scriptable object reference as an argument. The following expression would make the data table in use by the second Bivariate object the current data table:
Assign a name to a data table by sending it the Set Name message. The argument is a filename in quotation marks, or something that evaluates to a filename.
To retrieve the name, send a Get Name message to the data table:
To save a data table, send a Save message to the data table. Here are some examples:
On Windows, saving with a .txt extension exports according to the Text Export preferences. On Macintosh, add Text as a second argument to the Save function, as follows:
If you plan to set the name of a data table and later send the Save message, you can just specify the name in a Save message.
Including Save and the pathname is also an alternative to using Save As along with the pathname.
An invisible data table is hidden from view but linked to analyses that you run on it. Open a data table as an invisible file as follows:
Here is an example of creating an invisible table, called Abc, that has ten rows. One column is named X.
To find out if an open data table is invisible, pass the Boolean Has Data View message to the data table object. The following expression returns 0 (false) if the data table is invisible:
dt << Has Data View();
After you are finished with an invisible data table, do not forget to close it with the Close() function. Otherwise, the data table remains in memory until you quit JMP.
The Show Window() function shows an invisible data table.
The user has the option of opening the table from the JMP interface. On Windows, an invisible data table appears in the Window List on the Home Window and the Window > Unhide menu. On Macintosh, the data table appears in the JMP Home window and the Window > Hidden menu.
Print a data table by sending it a Print Window message. JMP uses your computer’s default printer settings.
dt << Maximize Display forces the data table to re-measure all of its columns and zoom to the best-sized window.
To close a data table, use a Close command with the data table’s reference as the argument. Data tables with unsaved changes are saved automatically, including any linked tables. Reports and graphs generated from the data tables are also closed.
Tip: Close All() also works with journals and layouts. Specify “Journals” or “Layouts” in the argument.
When using a DataBrowserBox created using New Data Box(), use Set Data Table() and Get Data Table() to set and return a data table.
The following example uses the Big Class.jmp and cities.jmp sample data tables. The sample data tables are opened invisibly. In a new window, a new data box is created containing Big Class.jmp. After waiting 1 second, the data box contents change to display cities.jmp.
openDTs now is a list of references to all open data tables. You can send messages to any one by using openDTs(n). You can use a for loop to send messages to all of the open data tables. This loop adds a new column named My Column to each open data table.
You can also create a new journal window and immediately add to it within the New Window() command. The following examples create an empty untitled journal and layout:
Similar to Freeze All but only within areas of a report called pictures.
Similar to Freeze Pictures but only within frame boxes (which are within pictures).
Similar to Freeze Frames but only for the frame boxes that have scripts to draw something on them.
Current Journal() returns a reference to the display box at the top of the current journal display window. If no journal is open, one is created. There are no arguments.