To add rows, send an Add Rows message and specify how many rows. You can also specify after which row to insert the new rows. The arguments can either be numbers or expressions that evaluate to numbers.
A variation of Add Rows lets you specify an argument yielding a list of assignments. Assignments can be separated with commas or semicolons.
To delete rows, send a Delete Rows message and specify which row or rows to delete. To delete more than one row, give a list or matrix as the rownum argument, or combine Delete Rows with other commands such as For. The rownum argument can be a number, list of numbers, range of numbers, matrix, or an expression that yields one of these. Without an argument, Delete Rows deletes the currently selected rows. With neither an argument nor rows selected, Delete Rows does nothing.
Here is a general way to remove the bottom x rows of a data table of any size. The following example removes 5 rows from the bottom of a data table:
NRow counts the rows in the table. For more details, see Iterate a Script on Each Row.
Select All Rows selects (or highlights) all of the rows in a data table.
If all rows are selected, you can deselect them all by using Invert Row Selection. This command reverses the selection state for each row, so that any selected rows are deselected, and any deselected rows are selected.
Note: With the exception of Invert Row Selection, whose result depends on the current selection, any new selection message starts over with a new selection. If you already have certain rows selected and you then send a new message to select rows, all rows are first deselected.
To select specific rows in a data table based on their row number, use the Select Rows command. The argument to the command is a list of row numbers. For example, to select rows 1, 3, 5, and 7 of a data table, proceed as follows:
To select rows according to data values, use Select Where, specifying a logical test inside the parentheses.
For example, using the Big sample data table, select the rows where the students’ age is greater than 13:
To select a row without deselecting a previously selected row, combine << Select Where with << Select Where and the current selection("extend") argument. This is an alternative to using an OR statement.
To select rows that are not excluded, hidden, or labeled, stack a select message and an invert selection message together in the same statement, or send the two messages sequentially:
To refer to a specific cell, assign a subscript to the cell’s row number. In the following example, the subscript [1] is used with the weight column. The formula then calculates the ratio between each height and the first value in the weight column.
The row menu command Select Matching Cells is also implemented in JSL.
Get Rows returns a matrix of rows that match the specified condition. The following example select rows in which the age is greater than or equal to 16:
Next Selected and Previous Selected scroll the data table window up or down so that the next selected row that is not already in view moves into view. The table wraps, so Next Selected jumps from the bottom-most selected row to the top-most, and vice versa for Previous Selected.
You can use the Colors and Markers messages to assign (or change) colors and markers used for rows. These settings mostly affect graphs produced from the data table. Both messages expect numeric arguments to choose which color or marker to use. For details about how numbers correspond to colors and markers, see Colors and Markers.
Color by Column sets colors according to the values of a column that you specify, and Marker by Column works similarly:
Continuous Scale (Color by Column only) Assigns colors in a chromatic sequential fashion based on the values in the highlighted column.
Reverse Scale Reverses the color scheme in use.
Make Window with Legend Creates a separate window with a legend.
Excluded Rows Applies the row states to excluded columns.
Marker Theme Specifies the marker type.
Color Theme Specifies the color theme.
You can color cells based on specific values. The following example colors the cells in the height column. All cells containing a value greater than 60 are blue. All cells containing a value equal to or less than 60 are purple.
Note: The first argument for Color Cells represents the color value. The second argument contains the row numbers.
Use the Hide, Exclude, and Label messages to hide, exclude, and label rows. These messages are toggles, meaning that to turn the messages on you send them once, and to turn them off you send the message a second time. They also accept Boolean arguments to explicitly turn them off and on.
For example, to hide all rows in Big Class where age is greater than 13, you could do the following:
Generally, an expression is executed on the current row of the data table only. Some exceptions are the expressions inside formula columns, Summarize and the pre-evaluated statistics operators, and any use of data table columns by analysis platforms.
Note: The current row for scripting is not related to rows being selected (or highlighted) in the data table or to the current cursor position in the data table window. The current row for scripting is defined to be zero (no row) by default.
For Each Row executes the script once for each row of the current data table. Note that Row()=1 only lasts for the duration of the script, then Row() reverts to its default value, which is zero. This means that submitting a script all at once can produce different results than submitting a script a few lines at a time.
By default, the current row number is 0. The first row in a table is row 1, so row 0 is essentially not a row. In other words, by default, an operation is done on no rows. Unless you take action to set a current row or to specify some set of rows, you get missing values due to the lack of data. For example, a column name returns the value of that column on the current row. Scope the column name with the prefix : operator to avoid ambiguity (to force the name to be interpreted as a column name).
You can use the Row() operator to get or set the current row number. Row() is an example of an L-value expression in JSL: an operator that returns its value unless you place it before an assignment operator (=, +=, and so on.) to set its value.
The N Rows and N Cols operators return the rows and columns in a data table.
N Rows and N Cols also count the number of rows in matrices. Note that NRow and NCol are synonyms. See the Inquiry Functions in Data Structures for details.
You can use For Each Row to set row states instead of creating a new formula column in the data table. The scripts below are similar, except that the first one creates a row state column, and the For Each Row script simply sets the row state without creating a column.
You can use Break and Continue to control the execution of a For Each Row loop. For more information, see Break and Continue in JSL Building Blocks.
Dif and Lag are special operators that can be useful for statistical computations, particularly when working with time series or cumulative data.
Lag returns the value of a column n rows before the current row.
Dif returns the difference between the value in the current row and the value n rows previous.
Sequence() corresponds to the Sequence function in the Formula Editor and is used to fill the cells in a data table column. It takes four arguments and the last two are optional:
From and to are not optional. They specify the range of values to place into the cells. If from = 4 and to = 8, the cells are filled with the values 4, 5, 6, 7, 8, 4, ...
Stepsize is optional. If you do not specify a stepsize, the default value is 1. Stepsize increments the values in the range. If stepsize = 2 with the above from and to values, the cells are filled with the values 4, 6, 8, 4, 6, ...
Repeat is optional. If you do not specify a Repeat, the default value is 1. Repeat specifies how many times each value is repeated before incrementing to the next value. If repeat = 3 with the above from, to, and stepsize values, the cells are filled with the values 4, 4, 4, 6, 6, 6, 8, 8, 8, 4, .... If you specify a Repeat value, you must also specify a Stepsize value.
Because Sequence() is a formula function, you can also set a column's formula to use Sequence() to fill the column. The following example creates a new column named Formula Sequence and adds a formula to it. The formula is a sequence that fills the column with values between 25 and 29, incremented by 1, and repeated twice (25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 25, ...).
Sequence(1,5) produces 1,2,3,4,5,1,2,3,4,5,1, ...
Sequence(1,5,1,2) produces 1,1,2,2,3,3,4,4,5,5,1,1, ...
Sequence(10,50,10) produces 10,20,30,40,50,10, ...
10*Sequence(1,5,1) also produces 10,20,30,40,50,10, ...
Sequence(1,6,2) produces: 1,3,5,1,3,5, ... The limit is never reached exactly.
Note: If you want a matrix of values, then use the Index function, not Sequence.
Row states change how JMP works with your data. Row States explains each row state. Remember that you can use several row states at once to get the combination of effects that you want.
If rows are hidden, JMP does not show them in plots. However, the rows are still included in text reports and charts. (To omit points from reports and charts, use Exclude. To omit points from all results, use both Exclude and Hide.)
Row State Operators shows a comparison chart of the different row state operators, so that you can see which operators convert row states to numbers and numbers to row states. It also includes the numbers that you can use with each operator.
Marker Of(rowstate)
Color Of(rowstate)
To assign a row state using JSL, use Select Where to indicate which rows are affected, and then specify which row state to assign to the rows. In the following example, marker type 5 (a triangle) is assigned to rows in which sex is “F”.
A row state column is a dedicated column that stores row state information, but does not put the information into effect. You can then use For Each Row to put the row state column into effect. For more information about row state columns, see the Using JMP book.
Table with No Row States (left) and Table with Row States (right)
From JSL, you can set or get row states directly using the Row State operator. You can set or get the state for row n with Row State(n). If you do not supply an argument, you set or get the current row. To work with all rows, either use a For Each Row loop or work with formula columns.
Be careful whether you set every aspect of Row State() or just one aspect of it, such as Color Of( Row State() ). To see how this works, first color and mark all the rows:
Operators that take number arguments and either return states or accept state assignments all have the word “State” in their names: Row State, As Row State, Color State, Combine States, Excluded State, Hidden State, Hue State, Labeled State, Marker State, Selected State, Shade State.
Operators that take row state arguments (and assume that the argument Row State() if none is given) and operators that return or are set to numbers are either one word, or their second word is “Of”: Color Of, Excluded, Hidden, Labeled, Marker Of, Selected.
Row State Operators is a helpful comparison chart for these operators.
To get a row state and store it in a global, place Row State() on the right side of an assignment, as follows:
You can get or set many characteristics at once by combining state settings inside Combine States. You can also get or set each characteristic one at a time, the ultimate row state being the accumulation of characteristics. The following example uses Big Set green Y markers for males, but hide them in plots for now. Set red X markers for females and do not hide them in plots.
Notice that JMP returns a Combine State combination. This is because a row state datum is not just the state of one characteristic, such as color, but the cumulative state   of all the characteristics that have been set: exclusion, hiding, labeling, selection, markers, colors, hues, and shades. A list of such characteristics is called a row state combination.
Just as there can be many row state characteristics in effect, a row state column can have multiple characteristic row states as its values.
In addition to the overall Row State operator for getting or setting all the characteristics of a row state, there are separate operators to get or set one characteristic at a time preemptively. That is, to give a row one characteristic, canceling any other characteristics that might be in effect. The operators that set one characteristic and cancel others are as follows: Color State, Combine States, Excluded State, Hidden State, Hue State, Labeled State, Marker State, Selected State, Shade State.
A row state is not just one characteristic, but many. To work with just one characteristic at a time, use one of the L-value operators with Row State on either side of the equal sign. The side of the equal sign depends on whether you want to get or set a characteristic. There is an L-value operator for each of the following characteristics: Color Of, Excluded, Hidden, Labeled, Marker Of, Selected.
The MakeRowStateHandler message (sent to a data table object) obtains a callback when the row states change. For example,
Excluded gets or sets an excluded index. The index is 1 for true or 0 for false, indicating whether each row is excluded.
Hidden gets or sets a hidden index, which is 1 for hidden or 0 for not hidden.
Labeled gets or sets a labeled index, which is 1 for labeled or 0 for not labeled.
Selected gets or sets a selected index, which is 1 for selected or 0 for not selected.
Excluded State, Hidden State, Labeled State, and Selected State do the reverse; they get or set a row state condition as true or false according to the argument. Nonzero values set the row state to true, and zero values set it to false. Missing values result in no change of state.
Another common way to use a -State command would be in a row state data column whose values could be added to the row state (for cumulative characteristics). The following example excludes each odd numbered row:
Color Of returns or sets the color index. The color index is a number from the JMP color map that corresponds to the row state, or a missing value if there is no assigned color.
Similarly, Marker Of returns or sets the marker index. The marker index is a number from the JMP marker map that corresponds to the active marker, or a missing value if there is no assigned marker.
Both Color Of and Marker Of accept any row state expression or column or Row State() as arguments. They also assume the argument Row State() if none is given (some examples are shown with, and some without).
Color State and Marker State are similar to Color Of and Marker Of, except they work in the opposite direction. Where the -Of functions turn actual states into indices, the -State functions turn indices into states.
JMP Markers
JMP Colors
Hue State and Shade State together are an alternative to Color State for choosing colors. You cannot select black, white, or the shades of gray when you use Hue State. For these, you must use Shade State alone, or Color State.
Hues and Shades
There are no -Of operators for Hue and Shade. Color Of returns the equivalent Color State index for a color row state that has been set with Hue State or Shade State. For example, the following example gives rows 4 and 5 the same dark red marker:
This section is an optional topic for advanced users who are interested in working with row states through their internal numeric codes.
It is also possible to assign row states through their internal numeric codes using the As Row State operator, which simply converts integers to their equivalent row states. For example, to assign row states according to the row number, you could do:
In addition, the Set Row States command enables you to submit a matrix of codes that assign the row states all at once. The matrix should have dimension (number of rows) by 1, and contain one entry for each row. The entries are the row state codes corresponding to the row’s desired state.
This example takes advantage of this method to develop a compact formula that distinguishes females and males with Xs and Ys, while excluding females from calculations, hiding males from plots, and assigning different colors for each age.
Recall that the logical = = operator is an equality test that returns 1 for true and 0 for false.