• Register

It is true that numeric functions take one numeric parameter and return one value.

So, what is a numeric function?

Numeric functions are used to perform the operations on numbers and return the numbers. Numeric functions can be used in any numeric expression on IF, SELECT, DO IF, LOOP IF, END LOOP IF, and COMPUTE commands. Numeric functions always return the numbers.

Variables as arguments:

Most numeric functions have variable or the list of variable as an argument like;

  • In numeric function with more than one argument, each argument is separated by commas. Blank spaces alone cannot be used to separate the variable name, expression, or constants.
  • Arguments must be enclosed in parentheses.

Example:

COMPUTE Square_Root = SQRT(var4);   // return the square root of the value of var4 for each case

COMPUTE Remainder = MOD(var4, 3); // return the remainder from dividing the value of var4 by 3

COMPUTE Average = MEAN.3(var1, var2, var3, var4); // return the mean of the four specified variables, provided that at least three of them have non-missing values.

COMPUTE Trunc_Mean = TRUNC(MEAN(var1 TO var4)); // Compute the mean of the values for the inclusive range of variables and then truncate the result. 

Note:

A mean will be calculated as long as at least one of the variables has a non-missing value for that case.

posted Jul 2 in php 3,890 points