Previous Page | Next Page

Functions and CALL Routines

SUMABS Function



Returns the sum of the absolute values of the non-missing arguments.
Category: Descriptive Statistics

Syntax
Arguments
Details
Examples
Example 1: Calculating the Sum of Absolute Values
Example 2: Calculating the Sum of Absolute Values When You Use a Variable List

Syntax

SUMABS(value-1 <,value-2 ...>)


Arguments

value

specifies a numeric expression.


Details

If all arguments have missing values, then the result is a missing value. Otherwise, the result is the sum of the absolute values of the non-missing values.


Examples


Example 1: Calculating the Sum of Absolute Values

The following example returns the sum of the absolute values of the non-missing arguments.

data _null_;
   x=sumabs(1,.,-2,0,3,.q,-4);
   put x=;
run;

SAS writes the following output to the log:

x=10


Example 2: Calculating the Sum of Absolute Values When You Use a Variable List

The following example uses a variable list and returns the sum of the absolute value of the non-missing arguments.

data _null_;
   x1 = 1;
   x2 = 3;
   x3 = 4;
   x4 = 3;
   x5 = 1;
   x = sumabs(of x1-x5);
   put x=;
run;

SAS writes the following output to the log:

x=12

Previous Page | Next Page | Top of Page