Spreadsheet Formulas - Math and Statistical Functions
When you can use predefined Math and Statistical functions in expressions:
Functions are not case sensitive. Example: Log(x) is the same as log(x) or LOG(x).
The return value of the function replaces the position of the function in the expression or spreadsheet formula.
Math functions
List of math function arguments:
Math functions can accept either one to two arguments, depending on the function.
When using Math functions, if the value of any variable you use in the expression or formula is missing (in the current case), then the expression evaluates to missing data (for the current case).
Acceptable arguments:
Math Functional Arguments | Example |
Numeric values. | Sqrt(155) |
Variable names | Max(SCORE1,SCORE9) |
Variable numbers | Log(v8) |
Expressions that evaluate to a number | Max(v7,(v5+v8-BASELINEVALUE)/3) |
Functions that return a numeric result | Sin(Sqrt(v5) |
Some commonly used constants, specified in expressions and formulas by reference. | Pi = 3.14... Euler (e) = 2.71... |
Statistics functions
These nine statistics functions can accept lists of values and ranges and arguments and adjust to missing data:
Statistics Functions | Definition | |
mean | Mean(x1, x2,..xn) | mean of n arguments
Returns mean for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names |
median | Median(x1, x2,..xn) | 50th percentile of n arguments
Returns median for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names. |
perc25 | Perc25(x1, x2,..xn) | 25th percentile of n arguments
Returns 25th percentile (lower quartile) for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names. |
perc75 | Perc75(x1, x2,..xn) | 75th percentile of n arguments
Returns 75th percentile (upper quartile) for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names. |
statmax | Statmax(x1, x2,..xn) | maximum of n arguments
Returns maximum value among the specified arguments and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names. |
statmin | Statmin(x1, x2,..xn) | minimum of n arguments
Returns minimum value among the specified arguments and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names. |
stdev | Stdev(x1, x2,..xn) | standard deviation of n arguments
Returns standard deviation for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names |
sum | Sum(x1, x2,..xn) | sum of n arguments
Returns sum for specified variable range. Variables in argument can be referenced by vXXX convention or by names. |
validn | Validn(x1, x2,..xn) | number non-missing of n arguments
Returns number of valid cases for specified variable range and/or list (e.g., v1:v3, AGE, sqrt(v9+100),v11:v15, will include 10 elements). Variables in argument can be referenced by vXXX convention or by names |
VARMAX | VARMAX(varref) | Returns the max of the specified variable/column |
VARMEAN | VARMEAN(varref) | Returns the mean of the specified variable/column |
VARMIN | VARMIN(varref) | Returns the min of the specified variable/column |
VARSTDDEV | VARSTDDEV(varref) | Returns the std. dev. of the specified variable/column |
VARSUM | VARSUM(varref) | Returns the sum of the specified variable/column |
VARVALIDN | VARVALIDN(varref) | Returns the valid N of the specified variable/column |
Ways statistic functions differ from math functions:
- They ignore arguments that contain missing values. They base their results on non-missing data only.
- Each statistics function accepts any number of arguments placed in parentheses and separated by commas.
- Statistics functions do not evaluate to a missing result except in the following circumstances:
All arguments are missing values.
An argument is encountered that evaluates to an undefined value. Example: Square root of a negative number or division by zero.
List of acceptable statistics function arguments:
Statistical Function Arguments | Example |
Numbers | Mean(18,80,120,68,40) |
Variable names | Mean(SALARY,1050,BONUS,500) |
Variable numbers | Stdev(120,v3,v2,v8,255) |
Ranges of variables designated by name or number (use colons to define ranges) | Sum(v54,COST1:COST5,2550,v23:v35,1575,OVERHEAD) |
Expressions that evaluate to a number | Mean(500,(v6+456)/v3),TRAVELEXPENSE,v8) |
Functions that return a numeric result | Mean(220,Sqrt(v8+v7),v12) |
See also: Distributions and their Functions, Spreadsheet Formulas - Overview, Spreadsheet Formulas - Syntax Summary, Spreadsheet Formulas - Examples, Spreadsheet Formulas - Syntax Operators, Spreadsheet Formulas - Distributions and their Functions.