Publication date: 08/13/2020

And(a, b)

a&b

Description

Logical And.

Returns

1 (true) if both a and b are true.

0 (false) if either a or b is false or if both a and b are false.

Missing if either a or b is a missing value or if both a and b are missing values.

Arguments

Two or more variables or expressions.

Notes

More than two arguments can be strung together. a&b returns 1 (true) only if all arguments evaluate to true.

AndMZ(a, b)

a:&b

Description

Returns the logical AND of all arguments. Missing values are treated as zeroes.

Returns

1 (true) if both a and b are true.

0 (false) if either a or b is false or if both a and b are false.

0 (false) if either a or b is a missing value or if both a and b are missing values.

Arguments

Two or more variables or expressions.

Notes

More than two arguments can be strung together. a:&b returns 1 (true) only if all arguments evaluate to true.

Break()

Description

Stops execution of a loop completely and continues to the statement following the loop.

Note

Break works with For and While loops, and also with For Each Row.

Choose(expr, r1, r2, r3, ..., rElse)

Description

Evaluates expr. If the value of expr is 1, r1 is returned; if 2, the value of r2 is returned, and so on. If no matches are found, the last argument (rElse) is returned.

Returns

The value whose index in the list of arguments matches expr, or the value of the last argument.

Arguments

expr

an expression or a value.

r1, r2, r3, ...

an expression or a value.

Continue()

Description

Ends the current iteration of a loop and begins the loop at the next iteration.

Note

Continue works with For and While loops, and also with For Each Row.

For(init, while, increment, body)

Description

Repeats the statement(s) in the body as long as the while condition is true. Init and increment control iterations.

Returns

Null.

Arguments

init

Initialization of loop control counter.

while

Condition for loop to continue or end. As long as the conditional statement while is true, the loop is iterated one more time. As soon as while is false, the loop is exited.

increment

Increments (or decrements) the loop counter after while is evaluated every time the loop is executed.

body

Any number of valid JSL expressions, glued together if there are more than one.

Example

mysum = 0; myprod = 1;

For( i = 1, i <= 10, i++, mysum += i; myprod *= i; );

`Show( mysum, myprod );`

mysum = 55;

myprod = 3628800;

For Each Row(<dt,> script)

Description

Repeats the script on each row of the data table.

Returns

Null.

Argument

dt

Optional positional argument: a reference to a data table. If this argument is not in the form of an assignment, then it is considered a data table expression.

script

Any valid JSL expressions.

Example

The following example creates data table references and then iterates over each row in Big Class.jmp. If the value of age in a row is greater than 15, the age is printed to the log.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

For Each Row( dt, If( :age > 15, Show( :age ) ) );

If(condition1, result1, <condition2, result2,> ..., <elseResult>)

Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression associated with the first condition argument that evaluates to a nonzero result. The condition arguments are evaluated in order. If all of the condition arguments evaluate to zero, the optional elseResult is evaluated and the result is returned. If no elseResult is specified, and none of the conditions are true, a missing value is returned. If all of the condition arguments evaluate to missing, a missing value is returned.

IfMax(expr1, result1, expr2, result2, ... <all missing result>)

Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression (the second of each pair) associated with the maximum of the expressions. If more than one expression is the maximum, the first maximum is returned. If all expressions are missing and a final result is not specified, missing is returned. If all expressions are missing and a final result is specified, that final result is returned. The test expressions must evaluate to numeric values, but the result expressions can be anything.

Returns

The result expression associated with the maximum of the expressions

IfMin(expr1, result1, expr2, result2, ... <all missing result>)

Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression (the second of each pair) associated with the minimum of the expressions. If more than one expression is the minimum, the first minimum is returned. If all expressions are missing and a final result is not specified, missing is returned. If all expressions are missing and a final result is specified, that final result is returned. The test expressions must evaluate to numeric values, but the result expressions can be anything.

Returns

The result expression associated with the minimum of the expressions

IfMZ(condition1, result1, <condition2, result2,> ..., <elseResult>)

Description

Evaluates the first of each pair of arguments and returns the evaluation of the result expression associated with the first condition argument that evaluates to a nonzero result. The condition arguments are evaluated in order. If all of the condition arguments evaluate to zero or missing, the optional elseResult is evaluated and the result is returned. If no elseResult is specified, and none of the conditions are true, a missing value is returned.

Notes

The test arguments are evaluated in order until the first nonzero result. If all test results return zero or missing, the elseExpr argument is evaluated.

IfMZ() is equivalent to If() where missing values for evaluated condition arguments are treated as zero.

Interpolate(x, x1, y1, x2, y2)

Interpolate(x, xmatrix, ymatrix)

Description

Linearly interpolates the y-value corresponding to a given x-value between two points (x1, y1), and (x2, y2) or by matrices xmatrix and ymatrix. The points must be in ascending order.

Is Associative Array(name)

Description

Returns 1 if the evaluated argument is an associative array, or 0 otherwise.

Is Empty(global)

Is Empty(dt)

Is Empty(col)

Description

Returns 1 if the global variable, data table, or data column is undefined or holds the Empty() value, or 0 otherwise.

Is Expr(x)

Description

Returns 1 if the evaluated argument is an expression, or 0 otherwise.

Is List

See Is List(x).

Is Name(x)

Description

Returns 1 if the evaluated argument is a name, or 0 otherwise.

Is Namespace(namespace)

Description

Returns 1 if the namespace argument is a namespace; returns 0 otherwise.

Is Number(x)

Description

Returns 1 if the evaluated argument is a number or missing numeric value, or 0 otherwise.

Is Scriptable(x)

Description

Returns 1 if the evaluated argument is a scriptable object, or 0 otherwise.

Is String(x)

Description

Returns 1 if the evaluated argument is a string, or 0 otherwise.

Match(x, value1, result1, value2, result2, ..., resultElse)

Description

If a is equal to value1, then result1 is returned. If a is equal to value2, result2 is returned, and so on.

Note

The Match() function explicitly checks to see if the compare expression x is missing and if the value of value1 is missing, then it returns the value of result1; otherwise it continues to compare the expression x to each valueN value in each valueN/resultN pair, ignoring any missing values. If the expression x is equal to any of the valueN value, then the corresponding resultN value is returned. If no matching valueN value is found, then the resultElse value is returned.

MatchMZ(x, value1, expr1, value2, expr2, ..., exprElse)

Description

Evaluates and returns the exprN argument that equals x or evaluates and returns the exprElse argument if no value equals x.

Note

The MatchMZ() function works the same as the Match() function except that missing values are treated as 0.

Not(a)

!a

Description

Logical Not.

Returns

0 (false) if a>0.

1 (true) if a<=0.

Missing value if a is missing.

Argument

a

Any variable or number. The variable must have a numeric or matrix value.

Notes

Mostly used for conditional statements and loop control.

Or(a, b)

a|b

Description

Logical Or.

Returns

1 (true) if either of or both a and b are true.

0 (false) otherwise.

Missing if either are missing.

Arguments

a, b

Any variable or number.

Notes

Mostly used for conditional statements and loop control.

OrMZ(a, b)

a :| b

Description

Returns the logical OR of all arguments with missing values treated as zeroes: 1 if any arguments are nonzero and 0 otherwise.

Returns

1 (true) if either of or both a and b are true.

0 (false) otherwise.

Arguments

a, b

Any variable or number.

Notes

Mostly used for conditional statements and loop control. When opening a JMP 3 data table, this function is automatically used for any Or function.

Or() returns missing if any evaluated argument is missing. OrMZ() returns 0 if any evaluated argument is missing.

Return(<Expr1>, <Expr2>, ..., <ExprN>)

Description

Returns an expression value from a user-defined function.

Example

This example returns the evaluation of both expressions in the Return() function as a list. The Return() function can have more than one argument. If only one is present, then the value of the expression is returned. If more than one is present, then the values of all the expressions is returned in a list.

`f = Function( {a, b},`

` Return( a - b, a + b )`

);

{lo, hi} = f( 10, 1 );

`Show( lo, hi );`

Show( f( 7, 15 ) );

lo = 9;

hi = 11;

f(7, 15) = {-8, 22};

Note

Return() not enclosed by a function, method, or recursive function call causes an error.

Step(x0, x1, y1, x2, y2, ...)

Step(x0, [x1, x2, ...], [y1, y2, ...])

Description

Returns the y argument corresponding to the largest x argument that is less than or equal to x0. The x points must be specified in ascending order.

Stop()

Description

Immediately stops a script that is running.

While(expr, body)

Description

Repeatedly tests the expr condition and executes the body until the expr condition is no longer true.

Zero Or Missing(expr)

Description

Returns 1 if expr yields a missing value or zero, 0 otherwise.

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

.