The following elements can be part of a numeric expression:
There are two situations where the result of the evaluation of an expression is undefined and SPSS returns a SYSMIS value:
If an operation implies a missing value and 0, the result is not always SYMIS, for instance [mv is a missing value] 0*mv, 0/mv will produce 0 (as do 0**mv or MOD(0,mv).
+ | add |
- | subtract |
* | multiply |
/ | divide |
** | exponentiation |
Name | Explanation | Example, comment |
---|---|---|
ABS(arg) | Absolute value | ABS(G1-G2) |
RND(arg) | Rounding | RND(PNB/HABIT) |
TRUNC(arg) | Integer part (truncate) | TRUNC(PNB/HABIT) |
MOD(arg,arg) | modulo | MOD(PNB/HABIT,10) |
SQRT(arg) | Square root | SQRT(GNP) |
EXP(arg) | e to the power of arg | |
LG10(arg) | logarithm base 10 | |
LN(arg) | Natural log | |
ARSIN(arg) | arc sine | result in radians |
ARTAN(arg) | arc tangent | result in radians |
SIN(arg) | sine | result in radians |
COS(arg) | cosine | result in radians |
This list is not exhaustive. |
arg may be a simple argument or a numeric expression. The result
Statistical functions compute for each case a summary statistic across all variables specified as argument to the function (varlis).
SUM (varlis) | Sum |
MEAN(varlis) | Mean |
SD(varlis) | Standard Deviation |
VARIANCE(varlis) | Variance |
CFVAR(varlis) | Coefficient of variation |
MIN(varlis) | Minimum |
MAX(varlis) | Maximum |
VALUE(varnam) | User missing values are treated as non-missing |
NMISS(varlis) | Number of missing values in varlis |
NVALID(varlis) | Number of valid values in varlis |
See also the SYSMIS() and MISSING() logical functions explained here with logical expressions
SPSS has a large number of specialized functions, useful when working with time data (time and date oriented functions and lags), string and conversion functions, as well as functions dealing with random variables and (statistical) distributions. The table below shows just a few, common ones as an example.
LAG(arg,n) | Create a lagged time series (n is the lag). |
DATEDIFF | Difference in days between two dates. |
XDATE.WKDAY | Day of the week |
RV.NORMAL(m,sd) | Normally distributed random numbers with mean=m and standard deviation=sd |
RV.CHISQ(df) | Random numbers based on chi-square distribution with df degrees of freedom |
CDF.LAPLACE | Cumulative Laplace distribution |