This version of the Help is no longer updated. See JMP.com/help for the latest version.

.
Publication date: 07/30/2020

Operators

An operator is a one- or two-character symbol used to perform common arithmetic actions, compare values, construct lists, subscript into a data element, send messages, concatenate lists, scope names, glue expressions, and end expressions.

Arithmetic operators come in several varieties:

infix (with arguments on either side, such as + in 3 + 4, or = in a = 7)

prefix (with one argument on its right side, such as !a for logical negation)

or postfix (with one argument on its left side, such as a++ for incrementing a

To make writing expressions easier, JSL uses certain special character operators that are alternatives to using functions. These operators have the same meaning as if the phrase had been written as a function. For example, the following two expressions are equivalent.

Net Income After Taxes = Net Income - Taxes;
Assign( Net Income After Taxes, Subtract( Net Income, Taxes ) );

The assignment operation can be written either as the Assign() function or as an infix operator =. Similarly, subtraction can be done with the Subtract() function or the infix minus sign; they are equivalent inside JMP.

Note: Usually white space is ignored in JSL, so that “netincomeaftertaxes” and “net income after taxes” are the same thing. There is one exception: the two-character operators must not have a space between characters. Always enter the following operators without spaces in between:

||, |/, <=, >=, !=, ==, +=, -=, *=, /=,  ++, --, <<, ::, :*, :/, /*, */

Another common operator is the semicolon ( ; ). You use the semicolon to:

Separate yet join one expression to another in a programming sequence. The semicolon returns the result of its last argument, so a;b is the same as Glue(a,b).

End an expression. Though the semicolon is permitted at the end of an expression, it is not the expression terminator used in other languages.

An expression can contain more than one operator. In these instances, the operators are grouped in order of precedence with decreasing priority. For example, * takes precedence over +:

a + b * c

So b * c is evaluated first, and then the result is added to a.

+ takes precedence over -:

a + b * c - d

So b * c is evaluated, and then the result is added to a. d is then subtracted from the result of a + b * c.

Table 5.3 shows operators shaded in order of precedence and each operator’s function equivalent.

Table 5.3 Operators and Their Function Equivalents in Order of Precedence

Operator

Function Syntax

Explanation

{ }

List

{a,b}

List(a,b)

Construct a list.

[ ]

Subscript

a[b,c]

Subscript(a,b,c)

Subscripts identify specific elements within a data element a, where a could be a list, a matrix, a data column, a platform object, a display box, and so on.

++

Post Increment

a++

Post Increment(a)

Adds one (1) to a, in place.

JMP does not have a pre-increment operator. Instead, use the Add To() operator, which is (+=).

– –

Post Decrement

a– –

Post Decrement(a)

Subtracts one (1) from a, in place.

JMP does not have a pre-decrement operator. Instead, use the Subtract To() operator, which is (-=).

^

Power

a^b

Power(a,b)

Power(x)

Raise a to exponent power b. With only one argument, 2 is assumed as the power, so Power(x) computes x2.

Minus

a

Minus(a)

Reverses sign of a.

!

Not

!a

Not(a)

Logical Not. Maps nonzero (or true) values to 0 (which means false). Maps 0 (or false) values to 1 (which means true).

*

Multiply

a*b

Multiply(a,b)

Multiplies a by b.

:*

EMult

a:*b

EMult(a,b)

Elementwise multiplication for matrices a and b. (Each element in matrix a is multiplied by each element in matrix b.)

/

Divide

a/b

Divide(a,b)

Divide(x)

Divide(a, b) divides a by b.

Divide(x) interprets the argument as a denominator and implies 1 as the numerator, yielding the reciprocal 1/x.

:/

EDiv

a:/b

EDiv(a,b)

Elementwise division for matrices a and b. (Each element in matrix a is divided by each element in matrix b.)

+

Add

a+b

Add(a,b)

Adds a and b.

Subtract

ab

Subtract(a,b)

Subtracts b from a.

||

Concat

a||b

Concat(a,b)

Joins two or more strings; two or more lists; and horizontally concatenates matrices. See Concatenate Lists in the Data Structures section or the JSL Syntax Reference.

|/

VConcat

matrix1|/matrix2

VConcat(matrix1, matrix2)

Vertically concatenate matrices. (Use || or Concat() to horizontally concatenate matrices.)

::

Index

a::b

Index(a,b)

For matrices, generates the integers from a to b.

(Colons are also used as prefix operators for scoping, where :a means data table column a, and ::a means JSL global variable a. See Scoping Operators.)

<<

Send

object << message

Send(object, message)

Send message to object.

==

Equal

a==b

Equal(a,b)...

Boolean values for comparisons. They all return 1 if true, 0 if false. Missing values in either a or b causes a return value of missing, which evaluates as neither true nor false. See Missing Values, for treatment of missing values.

!=

Not Equal

a!=b

Not Equal(a,b)...

<

Less

a<b

Less(a,b)...

<=

Less or Equal

a<=b

Less or Equal(a,b)

>

Greater

a>b

Greater(a,b)

>=

Greater or Equal

a>=b

Greater or Equal(a,b)

<=, <

Less Equal Less

a<=b<c

Less Equal Less(a,b,c)

Range check. Return 1 if true, 0 if false. Missing values in either a or b propagate missing values.

<, <=

Less Less Equal

a<b<=c

Less Less Equal(a,b,c)

&

And

a&b

And(a,b)

Logical And. Returns true if both are true. If the value on the left is false, the value on the right is not evaluated. See Missing Values, for treatment of missing values.

|

Or

a|b

Or(a,b)

Logical Or. Returns true if either or both are true. See Missing Values, for treatment of missing values.

=

Assign

a=b

Assign(a,b)

Put the value of b into a. Replaces the current value of a.

+=

Add To

a+=b

AddTo(a,b)

Add the value of b into a.

– =

Subtract To

a– =b

SubtractTo(a,b)

Subtract b from a, and put back into a.

*=

Multiply To

a*=b

MultiplyTo(a,b)

Multiply b with a, and put back into a.

/=

Divide To

a/=b

DivideTo(a,b)

Divide b into a, and put back into a.

;

Glue

a;b

Glue(expr, expr, ...)

First do a, and then do b.

Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).