SIGN Function

Returns the sign of a value.

Categories:Mathematical
CAS
Note:Beginning in 2025.12 this function supports the BIGINT data type when run in the DS2 language. Set BIGINTPROCESSING=YES to ensure BIGINIT functionality. If any argument is DOUBLE, all arguments are converted to DOUBLE and the result is DOUBLE. If BIGINTPROCESSING=YES is set in the PROC DS2 statement and any argument is BIGINT, all arguments are converted to BIGINT and the result is BIGINT.

Syntax

SIGN(argument)

Required Argument

argument

specifies a numeric constant, variable, or expression.

Details

The SIGN function returns the following values:

-1

if argument < 0

0

if argument = 0

1

if argument > 0.

Example

data new;                                                                                                                               
   x=sign(-5);                                                                                                                            
   y=sign(5);                                                                                                                             
   z=sign(0);                                                                                                                             
   put x= y= z=;                                                                                                                          
run;

These statements produce these results:

x=-1 y=1 z=0
Last updated: August 12, 2026