Previous Page | Next Page

Functions and CALL Routines

SUM Function



Returns the sum of the nonmissing arguments.
Category: Descriptive Statistics

Syntax
Arguments
Examples

Syntax

SUM(argument,argument, ...)

Arguments

argument

specifies a numeric constant, variable, or expression. If all the arguments have missing values, then one of the following occurs:

  • If you use only one argument, then the value of that argument is returned.

  • If you use two or more arguments, then a standard missing value (.) is returned.

Otherwise, the result is the sum of the nonmissing values. The argument list can consist of a variable list, which is preceded by OF.

Examples

SAS Statements Results
x1=sum(4,9,3,8);
24
x2=sum(4,9,3,8,.);
24
x1=9;
x2=39;
x3=sum(of x1-x2);
48
x1=5; x2=6; x3=4; x4=9;
y1=34; y2=12; y3=74; y4=39;
result=sum(of x1-x4, of y1-y5);
183
x1=55;
x2=35;
x3=6;
x4=sum(of x1-x3, 5);
101
x1=7;
x2=7;
x5=sum(x1-x2);

0
y1=20;
y2=30;
x6=sum(of y:);

50

Previous Page | Next Page | Top of Page