SIGN: Returning the Sign of a Number

SIGN takes a numeric argument and returns the value -1 if the number is negative, 0 (zero) if the number is zero, and 1 if the number is positive.

Return the Sign of a Number

SIGN(number)

where:

number

Is a field containing a numeric value or a number.

Returning the Sign of a Number

The following request returns the sign of positive numbers, negative numbers, and zero (0).

TABLE FILE GGSALES
SUM DOLLARS NOPRINT AND COMPUTE
PLUSDOLL/I9 = IF DOLLARS GT 12000000 THEN DOLLARS ELSE 0;
SIGN1/I5 = SIGN(PLUSDOLL);
NEGDOLL/I9 = IF DOLLARS LT 12000000 THEN 0 ELSE -DOLLARS;
SIGN2/I5 = SIGN(NEGDOLL);
BY CATEGORY
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

The output is shown in the following image.

SIGN(-5.5) returns -1.

SIGN(4) returns 1.

SIGN(0) returns 0.