Mathematical Expressions
************************

Expressions share a common syntax each place they appear in pspp commands.  Expressions are made up of operands, which can be numbers, strings, or variable names, separated by operators. There are five types of operators: grouping, arithmetic, logical, relational, and functions.

Every operator takes one or more operands as input and yields exactly one result as output.  Depending on the operator, operands accept strings or numbers as operands.  With few exceptions, operands may be full-fledged expressions in themselves.

Boolean Values
==============

Some pspp operators and expressions work with Boolean values, which represent true/false conditions.  Booleans have only three possible values: 0 (false), 1 (true), and system-missing (unknown). System-missing is neither true nor false and indicates that the true value is unknown.

Boolean-typed operands or function arguments must take on one of these three values.  Other values are considered false, but provoke a warning when the expression is evaluated.

Strings and Booleans are not compatible, and neither may be used in place of the other.

Missing Values in Expressions
=============================

Most numeric operators yield system-missing when given any system-missing operand.  A string operator given any system-missing operand typically results in the empty string.  Exceptions are listed under particular operator descriptions.

String user-missing values are not treated specially in expressions.

User-missing values for numeric variables are always transformed into the system-missing value, except inside the arguments to the VALUE and SYSMIS functions.

The missing-value functions can be used to precisely control how missing values are treated in expressions.  See Missing Value Functions, for more details.

Grouping Operators
==================

Parentheses (()) are the grouping operators.  Surround an expression with parentheses to force early evaluation.

Parentheses also surround the arguments to functions, but in that situation they act as punctuators, not as operators.

Arithmetic Operators
====================

The arithmetic operators take numeric operands and produce numeric results.

A + B
     Yields the sum of A and B.

A - B
     Subtracts B from A and yields the difference.

A * B
     Yields the product of A and B.  If either A or B is 0, then the result is 0, even if the other operand is missing.

A / B
     Divides A by B and yields the quotient.  If A is 0, then the result is 0, even if B is missing.  If B is zero, the result is system-missing.

A ** B
     Yields the result of raising A to the power B.  If A is negative and B is not an integer, the result is system-missing.  The result of 0**0 is system-missing as well.

- A
     Reverses the sign of A.

Logical Operators
=================

The logical operators take logical operands and produce logical results, meaning ``true or false.''  Logical operators are not true Boolean operators because they may also result in a system-missing value.  See Boolean Values, for more information.

A AND B
A & B
     True if both A and B are true, false otherwise.  If one operand is false, the result is false even if the other is missing.  If both operands are missing, the result is missing.

A OR B
A | B
     True if at least one of A and B is true.  If one operand is true, the result is true even if the other operand is missing.  If both operands are missing, the result is missing.

NOT A
~ A
     True if A is false.  If the operand is missing, then the result is missing.

Relational Operators
====================

The relational operators take numeric or string operands and produce Boolean results.

Strings cannot be compared to numbers.  When strings of different lengths are compared, the shorter string is right-padded with spaces to match the length of the longer string.

The results of string comparisons, other than tests for equality or inequality, depend on the character set in use.  String comparisons are case-sensitive.

A EQ B
A = B
     True if A is equal to B.

A LE B
A <= B
     True if A is less than or equal to B.

A LT B
A < B
     True if A is less than B.

A GE B
A >= B
     True if A is greater than or equal to B.

A GT B
A > B
     True if A is greater than B.

A NE B
A ~= B
A <> B
     True if A is not equal to B.

Functions
=========

pspp functions provide mathematical abilities above and beyond those possible using simple operators.  Functions have a common syntax: each is composed of a function name followed by a left parenthesis, one or more arguments, and a right parenthesis.

Function names are not reserved.  Their names are specially treated only when followed by a left parenthesis, so that EXP(10) refers to the constant value e raised to the 10th power, but EXP by itself refers to the value of a variable called EXP.

The sections below describe each function in detail.

Mathematical Functions
----------------------

Advanced mathematical functions take numeric arguments and produce numeric results.

 -- Function: EXP (EXPONENT)
     Returns e (approximately 2.71828) raised to power EXPONENT.

 -- Function: LG10 (NUMBER)
     Takes the base-10 logarithm of NUMBER.  If NUMBER is not positive, the result is system-missing.

 -- Function: LN (NUMBER)
     Takes the base-e logarithm of NUMBER.  If NUMBER is not positive, the result is system-missing.

 -- Function: LNGAMMA (NUMBER)
     Yields the base-e logarithm of the complete gamma of NUMBER. If NUMBER is a negative integer, the result is system-missing.

 -- Function: SQRT (NUMBER)
     Takes the square root of NUMBER.  If NUMBER is negative, the result is system-missing.

Miscellaneous Mathematical Functions
------------------------------------

Miscellaneous mathematical functions take numeric arguments and produce numeric results.

 -- Function: ABS (NUMBER)
     Results in the absolute value of NUMBER.

 -- Function: MOD (NUMERATOR, DENOMINATOR)
     Returns the remainder (modulus) of NUMERATOR divided by DENOMINATOR.  If NUMERATOR is 0, then the result is 0, even if DENOMINATOR is missing.  If DENOMINATOR is 0, the result is system-missing.

 -- Function: MOD10 (NUMBER)
     Returns the remainder when NUMBER is divided by 10.  If NUMBER is negative, MOD10(NUMBER) is negative or zero.

 -- Function: RND (NUMBER)
     Takes the absolute value of NUMBER and rounds it to an integer. Then, if NUMBER was negative originally, negates the result.

 -- Function: TRUNC (NUMBER)
     Discards the fractional part of NUMBER; that is, rounds NUMBER towards zero.

Trigonometric Functions
-----------------------

Trigonometric functions take numeric arguments and produce numeric results.

 -- Function: ARCOS (NUMBER)
 -- Function: ACOS (NUMBER)
     Takes the arccosine, in radians, of NUMBER.  Results in system-missing if NUMBER is not between -1 and 1 inclusive. This function is a pspp extension.

 -- Function: ARSIN (NUMBER)
 -- Function: ASIN (NUMBER)
     Takes the arcsine, in radians, of NUMBER.  Results in system-missing if NUMBER is not between -1 and 1 inclusive.

 -- Function: ARTAN (NUMBER)
 -- Function: ATAN (NUMBER)
     Takes the arctangent, in radians, of NUMBER.

 -- Function: COS (ANGLE)
     Takes the cosine of ANGLE which should be in radians.

 -- Function: SIN (ANGLE)
     Takes the sine of ANGLE which should be in radians.

 -- Function: TAN (ANGLE)
     Takes the tangent of ANGLE which should be in radians. Results in system-missing at values of ANGLE that are too close to odd multiples of \pi/2. Portability: none.

Missing-Value Functions
-----------------------

Missing-value functions take various numeric arguments and yield various types of results.  Except where otherwise stated below, the normal rules of evaluation apply within expression arguments to these functions.  In particular, user-missing values for numeric variables are converted to system-missing values.

 -- Function: MISSING (EXPR)
     Returns 1 if EXPR has the system-missing value, 0 otherwise.

 -- Function: NMISS (EXPR [, EXPR]...)
     Each argument must be a numeric expression.  Returns the number of system-missing values in the list, which may include variable ranges using the VAR1 TO VAR2 syntax.

 -- Function: NVALID (EXPR [, EXPR]...)
     Each argument must be a numeric expression.  Returns the number of values in the list that are not system-missing.  The list may include variable ranges using the VAR1 TO VAR2 syntax.

 -- Function: SYSMIS (EXPR)
     When EXPR is simply the name of a numeric variable, returns 1 if the variable has the system-missing value, 0 if it is user-missing or not missing.  If given EXPR takes another form, results in 1 if the value is system-missing, 0 otherwise.

 -- Function: VALUE (VARIABLE)
     Prevents the user-missing values of VARIABLE from being transformed into system-missing values, and always results in the actual value of VARIABLE, whether it is valid, user-missing, or system-missing.

Set-Membership Functions
------------------------

Set membership functions determine whether a value is a member of a set. They take a set of numeric arguments or a set of string arguments, and produce Boolean results.

String comparisons are performed according to the rules given in Relational Operators.

 -- Function: ANY (VALUE, SET [, SET]...)
     Results in true if VALUE is equal to any of the SET values.  Otherwise, results in false.  If VALUE is system-missing, returns system-missing.  System-missing values in SET do not cause /NAME/ to return system-missing.

 -- Function: RANGE (VALUE, LOW, HIGH [, LOW, HIGH]...)
     Results in true if VALUE is in any of the intervals bounded by LOW and HIGH inclusive.  Otherwise, results in false. Each LOW must be less than or equal to its corresponding HIGH value.  LOW and HIGH must be given in pairs. If VALUE is system-missing, returns system-missing. System-missing values in SET do not cause /NAME/ to return system-missing.

Statistical Functions
---------------------

Statistical functions compute descriptive statistics on a list of values.  Some statistics can be computed on numeric or string values; other can only be computed on numeric values.  Their results have the same type as their arguments.  The current case's weighting factor (see WEIGHT) has no effect on statistical functions.

These functions' argument lists may include entire ranges of variables using the VAR1 TO VAR2 syntax.

Unlike most functions, statistical functions can return non-missing values even when some of their arguments are missing.  Most statistical functions, by default, require only 1 non-missing value to have a non-missing return, but /NAME/, /NAME/, and VARIANCE require 2. These defaults can be increased (but not decreased) by appending a dot and the minimum number of valid arguments to the function name.  For example, MEAN.3(X, Y, Z) would only return non-missing if all of X, Y, and Z were valid.

 -- Function: CFVAR (NUMBER, NUMBER[, ...])
     Results in the coefficient of variation of the values of NUMBER. (The coefficient of variation is the standard deviation divided by the mean.)

 -- Function: MAX (VALUE, VALUE[, ...])
     Results in the value of the greatest VALUE.  The VALUEs may be numeric or string.

 -- Function: MEAN (NUMBER, NUMBER[, ...])
     Results in the mean of the values of NUMBER.

 -- Function: MIN (NUMBER, NUMBER[, ...])
     Results in the value of the least VALUE.  The VALUEs may be numeric or string.

 -- Function: SD (NUMBER, NUMBER[, ...])
     Results in the standard deviation of the values of NUMBER.

 -- Function: SUM (NUMBER, NUMBER[, ...])
     Results in the sum of the values of NUMBER.

 -- Function: VARIANCE (NUMBER, NUMBER[, ...])
     Results in the variance of the values of NUMBER.

String Functions
----------------

String functions take various arguments and return various results.

 -- Function: CONCAT (STRING, STRING[, ...])
     Returns a string consisting of each STRING in sequence. CONCAT("abc", "def", "ghi") has a value of "abcdefghi". The resultant string is truncated to a maximum of 255 characters.

 -- Function: INDEX (HAYSTACK, NEEDLE)
     Returns a positive integer indicating the position of the first occurrence of NEEDLE in HAYSTACK.  Returns 0 if HAYSTACK does not contain NEEDLE.  Returns system-missing if NEEDLE is an empty string.

 -- Function: INDEX (HAYSTACK, NEEDLES, NEEDLE_LEN)
     Divides NEEDLES into one or more needles, each with length NEEDLE_LEN. Searches HAYSTACK for the first occurrence of each needle, and returns the smallest value.  Returns 0 if HAYSTACK does not contain any part in NEEDLE.  It is an error if NEEDLE_LEN does not evenly divide the length of NEEDLES.  Returns system-missing if NEEDLES is an empty string.

 -- Function: LENGTH (STRING)
     Returns the number of characters in STRING.

 -- Function: LOWER (STRING)
     Returns a string identical to STRING except that all uppercase letters are changed to lowercase letters.  The definitions of ``uppercase'' and ``lowercase'' are system-dependent.

 -- Function: LPAD (STRING, LENGTH)
     If STRING is at least LENGTH characters in length, returns STRING unchanged.  Otherwise, returns STRING padded with spaces on the left side to length LENGTH.  Returns an empty string if LENGTH is system-missing, negative, or greater than 255.

 -- Function: LPAD (STRING, LENGTH, PADDING)
     If STRING is at least LENGTH characters in length, returns STRING unchanged.  Otherwise, returns STRING padded with PADDING on the left side to length LENGTH.  Returns an empty string if LENGTH is system-missing, negative, or greater than 255, or if PADDING does not contain exactly one character.

 -- Function: LTRIM (STRING)
     Returns STRING, after removing leading spaces.  Other white space, such as tabs, carriage returns, line feeds, and vertical tabs, is not removed.

 -- Function: LTRIM (STRING, PADDING)
     Returns STRING, after removing leading PADDING characters. If PADDING does not contain exactly one character, returns an empty string.

 -- Function: NUMBER (STRING, FORMAT)
     Returns the number produced when STRING is interpreted according to format specifier FORMAT.  If the format width W is less than the length of STRING, then only the first W characters in STRING are used, e.g. NUMBER("123", F3.0) and NUMBER("1234", F3.0) both have value 123.  If W is greater than STRING's length, then it is treated as if it were right-padded with spaces.  If STRING is not in the correct format for FORMAT, system-missing is returned.

 -- Function: RINDEX (STRING, FORMAT)
     Returns a positive integer indicating the position of the last occurrence of NEEDLE in HAYSTACK.  Returns 0 if HAYSTACK does not contain NEEDLE.  Returns system-missing if NEEDLE is an empty string.

 -- Function: RINDEX (HAYSTACK, NEEDLE, NEEDLE_LEN)
     Divides NEEDLE into parts, each with length NEEDLE_LEN. Searches HAYSTACK for the last occurrence of each part, and returns the largest value.  Returns 0 if HAYSTACK does not contain any part in NEEDLE.  It is an error if NEEDLE_LEN does not evenly divide the length of NEEDLE.  Returns system-missing if NEEDLE is an empty string.

 -- Function: RPAD (STRING, LENGTH)
     If STRING is at least LENGTH characters in length, returns STRING unchanged.  Otherwise, returns STRING padded with spaces on the right to length LENGTH.  Returns an empty string if LENGTH is system-missing, negative, or greater than 255.

 -- Function: RPAD (STRING, LENGTH, PADDING)
     If STRING is at least LENGTH characters in length, returns STRING unchanged.  Otherwise, returns STRING padded with PADDING on the right to length LENGTH.  Returns an empty string if LENGTH is system-missing, negative, or greater than 255, or if PADDING does not contain exactly one character.

 -- Function: RTRIM (STRING)
     Returns STRING, after removing trailing spaces.  Other types of white space are not removed.

 -- Function: RTRIM (STRING, PADDING)
     Returns STRING, after removing trailing PADDING characters. If PADDING does not contain exactly one character, returns an empty string.

 -- Function: STRING (NUMBER, FORMAT)
     Returns a string corresponding to NUMBER in the format given by format specifier FORMAT.  For example, STRING(123.56, F5.1) has the value "123.6".

 -- Function: SUBSTR (STRING, START)
     Returns a string consisting of the value of STRING from position START onward.  Returns an empty string if START is system-missing, less than 1, or greater than the length of STRING.

 -- Function: SUBSTR (STRING, START, COUNT)
     Returns a string consisting of the first COUNT characters from STRING beginning at position START.  Returns an empty string if START or COUNT is system-missing, if START is less than 1 or greater than the number of characters in STRING, or if COUNT is less than 1.  Returns a string shorter than COUNT characters if START + COUNT - 1 is greater than the number of characters in STRING.  Examples: SUBSTR("abcdefg", 3, 2) has value "cd"; SUBSTR("nonsense", 4, 10) has the value "sense".

 -- Function: UPCASE (STRING)
     Returns STRING, changing lowercase letters to uppercase letters.

Time & Date Functions
---------------------

For compatibility, pspp considers dates before 15 Oct 1582 invalid. Most time and date functions will not accept earlier dates.

How times & dates are defined and represented
.............................................

Times and dates are handled by pspp as single numbers.  A time is an interval.  pspp measures times in seconds. Thus, the following intervals correspond with the numeric values given:

               10 minutes                        600
               1 hour                          3,600
               1 day, 3 hours, 10 seconds     97,210
               40 days                     3,456,000

A date, on the other hand, is a particular instant in the past or the future.  pspp represents a date as a number of seconds since midnight preceding 14 Oct 1582.  Because midnight preceding the dates given below correspond with the numeric pspp dates given:

                   15 Oct 1582                86,400
                    4 Jul 1776         6,113,318,400
                    1 Jan 1900        10,010,390,400
                    1 Oct 1978        12,495,427,200
                   24 Aug 1995        13,028,601,600

Functions that Produce Times
............................

These functions take numeric arguments and return numeric values that represent times.

 -- Function: TIME.DAYS (NDAYS)
     Returns a time corresponding to NDAYS days.

 -- Function: TIME.HMS (NHOURS, NMINS, NSECS)
     Returns a time corresponding to NHOURS hours, NMINS minutes, and NSECS seconds.  The arguments may not have mixed signs: if any of them are positive, then none may be negative, and vice versa.

Functions that Examine Times
............................

These functions take numeric arguments in pspp time format and give numeric results.

 -- Function: CTIME.DAYS (TIME)
     Results in the number of days and fractional days in TIME.

 -- Function: CTIME.HOURS (TIME)
     Results in the number of hours and fractional hours in TIME.

 -- Function: CTIME.MINUTES (TIME)
     Results in the number of minutes and fractional minutes in TIME.

 -- Function: CTIME.SECONDS (TIME)
     Results in the number of seconds and fractional seconds in TIME. (CTIME.SECONDS does nothing; CTIME.SECONDS(X) is equivalent to X.)

Functions that Produce Dates
............................

These functions take numeric arguments and give numeric results that represent dates.  Arguments taken by these functions are:

day
     Refers to a day of the month between 1 and 31.  Day 0 is also accepted and refers to the final day of the previous month.  Days 29, 30, and 31 are accepted even in months that have fewer days and refer to a day near the beginning of the following month.

month
     Refers to a month of the year between 1 and 12.  Months 0 and 13 are also accepted and refer to the last month of the preceding year and the first month of the following year, respectively.

quarter
     Refers to a quarter of the year between 1 and 4.  The quarters of the year begin on the first day of months 1, 4, 7, and 10.

week
     Refers to a week of the year between 1 and 53.

yday
     Refers to a day of the year between 1 and 366.

year
     Refers to a year, 1582 or greater.  Years between 0 and 99 are treated according to the epoch set on SET EPOCH, by default beginning 69 years before the current date (see SET EPOCH).

If these functions' arguments are out-of-range, they are correctly normalized before conversion to date format.  Non-integers are rounded toward zero.

 -- Function: DATE.DMY (DAY, MONTH, YEAR)
 -- Function: DATE.MDY (MONTH, DAY, YEAR)
     Results in a date value corresponding to the midnight before day DAY of month MONTH of year YEAR.

 -- Function: DATE.MOYR (MONTH, YEAR)
     Results in a date value corresponding to the midnight before the first day of month MONTH of year YEAR.

 -- Function: DATE.QYR (QUARTER, YEAR)
     Results in a date value corresponding to the midnight before the first day of quarter QUARTER of year YEAR.

 -- Function: DATE.WKYR (WEEK, YEAR)
     Results in a date value corresponding to the midnight before the first day of week WEEK of year YEAR.

 -- Function: DATE.YRDAY (YEAR, YDAY)
     Results in a date value corresponding to the day YDAY of year YEAR.

Functions that Examine Dates
............................

These functions take numeric arguments in pspp date or time format and give numeric results.  These names are used for arguments:

date
     A numeric value in pspp date format.

time
     A numeric value in pspp time format.

time-or-date
     A numeric value in pspp time or date format.

 -- Function: XDATE.DATE (TIME-OR-DATE)
     For a time, results in the time corresponding to the number of whole days DATE-OR-TIME includes.  For a date, results in the date corresponding to the latest midnight at or before DATE-OR-TIME; that is, gives the date that DATE-OR-TIME is in.

 -- Function: XDATE.HOUR (TIME-OR-DATE)
     For a time, results in the number of whole hours beyond the number of whole days represented by DATE-OR-TIME.  For a date, results in the hour (as an integer between 0 and 23) corresponding to DATE-OR-TIME.

 -- Function: XDATE.JDAY (DATE)
     Results in the day of the year (as an integer between 1 and 366) corresponding to DATE.

 -- Function: XDATE.MDAY (DATE)
     Results in the day of the month (as an integer between 1 and 31) corresponding to DATE.

 -- Function: XDATE.MINUTE (TIME-OR-DATE)
     Results in the number of minutes (as an integer between 0 and 59) after the last hour in TIME-OR-DATE.

 -- Function: XDATE.MONTH (DATE)
     Results in the month of the year (as an integer between 1 and 12) corresponding to DATE.

 -- Function: XDATE.QUARTER (DATE)
     Results in the quarter of the year (as an integer between 1 and 4) corresponding to DATE.

 -- Function: XDATE.SECOND (TIME-OR-DATE)
     Results in the number of whole seconds after the last whole minute (as an integer between 0 and 59) in TIME-OR-DATE.

 -- Function: XDATE.TDAY (DATE)
     Results in the number of whole days from 14 Oct 1582 to DATE.

 -- Function: XDATE.TIME (DATE)
     Results in the time of day at the instant corresponding to DATE, as a time value.  This is the number of seconds since midnight on the day corresponding to DATE.

 -- Function: XDATE.WEEK (DATE)
     Results in the week of the year (as an integer between 1 and 53) corresponding to DATE.

 -- Function: XDATE.WKDAY (DATE)
     Results in the day of week (as an integer between 1 and 7) corresponding to DATE, where 1 represents Sunday.

 -- Function: XDATE.YEAR (DATE)
     Returns the year (as an integer 1582 or greater) corresponding to DATE.

Time and Date Arithmetic
........................

Ordinary arithmetic operations on dates and times often produce sensible results.  Adding a time to, or subtracting one from, a date produces a new date that much earlier or later.  The difference of two dates yields the time between those dates.  Adding two times produces the combined time.  Multiplying a time by a scalar produces a time that many times longer.  Since times and dates are just numbers, the ordinary addition and subtraction operators are employed for these purposes.

Adding two dates does not produce a useful result.

Dates and times may have very large values.  Thus, it is not a good idea to take powers of these values; also, the accuracy of some procedures may be affected.  If necessary, convert times or dates in seconds to some other unit, like days or years, before performing analysis.

pspp supplies a few functions for date arithmetic:

 -- Function: DATEDIFF (DATE2, DATE1, UNIT)
     Returns the span of time from DATE1 to DATE2 in terms of UNIT, which must be a quoted string, one of years, quarters, months, weeks, days, hours, minutes, and seconds.  The result is an integer, truncated toward zero.

     One year is considered to span from a given date to the same month, day, and time of day the next year.  Thus, from Jan. 1 of one year to Jan. 1 the next year is considered to be a full year, but Feb. 29 of a leap year to the following Feb. 28 is not. Similarly, one month spans from a given day of the month to the same day of the following month.  Thus, there is never a full month from Jan. 31 of a given year to any day in the following February.

 -- Function: DATESUM (DATE, QUANTITY, UNIT[, METHOD])
     Returns DATE advanced by the given QUANTITY of the specified UNIT, which must be one of the strings years, quarters, months, weeks, days, hours, minutes, and seconds.

     When UNIT is years, quarters, or months, only the integer part of QUANTITY is considered.  Adding one of these units can cause the day of the month to exceed the number of days in the month.  In this case, the METHOD comes into play: if it is omitted or specified as closest (as a quoted string), then the resulting day is the last day of the month; otherwise, if it is specified as rollover, then the extra days roll over into the following month.

     When UNIT is weeks, days, hours, minutes, or seconds, the QUANTITY is not rounded to an integer and METHOD, if specified, is ignored.

Miscellaneous Functions
-----------------------

 -- Function: LAG (VARIABLE[, N])

     VARIABLE must be a numeric or string variable name.  LAG yields the value of that variable for the case N before the current one.  Results in system-missing (for numeric variables) or blanks (for string variables) for the first N cases.

     LAG obtains values from the cases that become the new active dataset after a procedure executes.  Thus, LAG will not return values from cases dropped by transformations such as SELECT IF, and transformations like COMPUTE that modify data will change the values returned by LAG.  These are both the case whether these transformations precede or follow the use of LAG.

     If LAG is used before TEMPORARY, then the values it returns are those in cases just before TEMPORARY.  LAG may not be used after TEMPORARY.

     If omitted, NCASES defaults to 1.  Otherwise, NCASES must be a small positive constant integer.  There is no explicit limit, but use of a large value will increase memory consumption.

 -- Function: YRMODA (YEAR, MONTH, DAY)
     YEAR is a year, either between 0 and 99 or at least 1582. Unlike other pspp date functions, years between 0 and 99 always correspond to 1900 through 1999.  MONTH is a month between 1 and 13.  DAY is a day between 0 and 31.  A DAY of 0 refers to the last day of the previous month, and a MONTH of 13 refers to the first month of the next year.  YEAR must be in range. YEAR, MONTH, and DAY must all be integers.

     YRMODA results in the number of days between 15 Oct 1582 and the date specified, plus one.  The date passed to YRMODA must be on or after 15 Oct 1582.  15 Oct 1582 has a value of 1.

 -- Function: VALUELABEL (VARIABLE)
     Returns a string matching the label associated with the current value of VARIABLE.  If the current value of VARIABLE has no associated label, then this function returns the empty string. VARIABLE may be a numeric or string variable.

Statistical Distribution Functions
----------------------------------

pspp can calculate several functions of standard statistical distributions.  These functions are named systematically based on the function and the distribution.  The table below describes the statistical distribution functions in general:

PDF.DIST (X[, PARAM...])
     Probability density function for DIST.  The domain of X depends on DIST.  For continuous distributions, the result is the density of the probability function at X, and the range is nonnegative real numbers.  For discrete distributions, the result is the probability of X.

CDF.DIST (X[, PARAM...])
     Cumulative distribution function for DIST, that is, the probability that a random variate drawn from the distribution is less than X.  The domain of X depends DIST.  The result is a probability.

SIG.DIST (X[, PARAM...)
     Tail probability function for DIST, that is, the probability that a random variate drawn from the distribution is greater than X.  The domain of X depends DIST.  The result is a probability.  Only a few distributions include an /NAME/ function.

IDF.DIST (P[, PARAM...])
     Inverse distribution function for DIST, the value of X for which the CDF would yield P.  The value of P is a probability.  The range depends on DIST and is identical to the domain for the corresponding CDF.

RV.DIST ([PARAM...])
     Random variate function for DIST.  The range depends on the distribution.

NPDF.DIST (X[, PARAM...])
     Noncentral probability density function.  The result is the density of the given noncentral distribution at X.  The domain of X depends on DIST.  The range is nonnegative real numbers.  Only a few distributions include an /NAME/ function.

NCDF.DIST (X[, PARAM...])
     Noncentral cumulative distribution function for DIST, that is, the probability that a random variate drawn from the given noncentral distribution is less than X.  The domain of X depends DIST.  The result is a probability.  Only a few distributions include an NCDF function.

The individual distributions are described individually below.

Continuous Distributions
........................

The following continuous distributions are available:

 -- Function: PDF.BETA (X)
 -- Function: CDF.BETA (X, A, B)
 -- Function: IDF.BETA (P, A, B)
 -- Function: RV.BETA (A, B)
 -- Function: NPDF.BETA (X, A, B, LAMBDA)
 -- Function: NCDF.BETA (X, A, B, LAMBDA)
     Beta distribution with shape parameters A and B.  The noncentral distribution takes an additional parameter LAMBDA. Constraints: A > 0, B > 0, LAMBDA >= 0, 0 <= X <= 1, 0 <= P <= 1.

 -- Function: PDF.BVNOR (X0, X1, RHO)
 -- Function: CDF.VBNOR (X0, X1, RHO)
     Bivariate normal distribution of two standard normal variables with correlation coefficient RHO.  Two variates X0 and X1 must be provided.  Constraints: 0 <= RHO <= 1, 0 <= P <= 1.

 -- Function: PDF.CAUCHY (X, A, B)
 -- Function: CDF.CAUCHY (X, A, B)
 -- Function: IDF.CAUCHY (P, A, B)
 -- Function: RV.CAUCHY (A, B)
     Cauchy distribution with location parameter A and scale parameter B.  Constraints: B > 0, 0 < P < 1.

 -- Function: CDF.CHISQ (X, DF)
 -- Function: SIG.CHISQ (X, DF)
 -- Function: IDF.CHISQ (P, DF)
 -- Function: RV.CHISQ (DF)
 -- Function: NCDF.CHISQ (X, DF, LAMBDA)
     Chi-squared distribution with DF degrees of freedom.  The noncentral distribution takes an additional parameter LAMBDA. Constraints: DF > 0, LAMBDA > 0, X >= 0, 0 <= P < 1.

 -- Function: PDF.EXP (X, A)
 -- Function: CDF.EXP (X, A)
 -- Function: IDF.EXP (P, A)
 -- Function: RV.EXP (A)
     Exponential distribution with scale parameter A.  The inverse of A represents the rate of decay.  Constraints: A > 0, X >= 0, 0 <= P < 1.

 -- Function: PDF.XPOWER (X, A, B)
 -- Function: RV.XPOWER (A, B)
     Exponential power distribution with positive scale parameter A and nonnegative power parameter B.  Constraints: A > 0, B >= 0, X >= 0, 0 <= P <= 1.  This distribution is a pspp extension.

 -- Function: PDF.F (X, DF1, DF2)
 -- Function: CDF.F (X, DF1, DF2)
 -- Function: SIG.F (X, DF1, DF2)
 -- Function: IDF.F (P, DF1, DF2)
 -- Function: RV.F (DF1, DF2)
     F-distribution of two chi-squared deviates with DF1 and DF2 degrees of freedom.  The noncentral distribution takes an additional parameter LAMBDA.  Constraints: DF1 > 0, DF2 > 0, LAMBDA >= 0, X >= 0, 0 <= P < 1.

 -- Function: PDF.GAMMA (X, A, B)
 -- Function: CDF.GAMMA (X, A, B)
 -- Function: IDF.GAMMA (P, A, B)
 -- Function: RV.GAMMA (A, B)
     Gamma distribution with shape parameter A and scale parameter B.  Constraints: A > 0, B > 0, X >= 0, 0 <= P < 1.

 -- Function: PDF.LANDAU (X)
 -- Function: RV.LANDAU ()
     Landau distribution.

 -- Function: PDF.LAPLACE (X, A, B)
 -- Function: CDF.LAPLACE (X, A, B)
 -- Function: IDF.LAPLACE (P, A, B)
 -- Function: RV.LAPLACE (A, B)
     Laplace distribution with location parameter A and scale parameter B.  Constraints: B > 0, 0 < P < 1.

 -- Function: RV.LEVY (C, ALPHA)
     Levy symmetric alpha-stable distribution with scale C and exponent ALPHA.  Constraints: 0 < ALPHA <= 2.

 -- Function: RV.LVSKEW (C, ALPHA, BETA)
     Levy skew alpha-stable distribution with scale C, exponent ALPHA, and skewness parameter BETA.  Constraints: 0 < ALPHA <= 2, -1 <= BETA <= 1.

 -- Function: PDF.LOGISTIC (X, A, B)
 -- Function: CDF.LOGISTIC (X, A, B)
 -- Function: IDF.LOGISTIC (P, A, B)
 -- Function: RV.LOGISTIC (A, B)
     Logistic distribution with location parameter A and scale parameter B.  Constraints: B > 0, 0 < P < 1.

 -- Function: PDF.LNORMAL (X, A, B)
 -- Function: CDF.LNORMAL (X, A, B)
 -- Function: IDF.LNORMAL (P, A, B)
 -- Function: RV.LNORMAL (A, B)
     Lognormal distribution with parameters A and B. Constraints: A > 0, B > 0, X >= 0, 0 <= P < 1.

 -- Function: PDF.NORMAL (X, MU, SIGMA)
 -- Function: CDF.NORMAL (X, MU, SIGMA)
 -- Function: IDF.NORMAL (P, MU, SIGMA)
 -- Function: RV.NORMAL (MU, SIGMA)
     Normal distribution with mean MU and standard deviation SIGMA.  Constraints: B > 0, 0 < P < 1.  Three additional functions are available as shorthand:

      -- Function: CDFNORM (X)
          Equivalent to CDF.NORMAL(X, 0, 1).

      -- Function: PROBIT (P)
          Equivalent to IDF.NORMAL(P, 0, 1).

      -- Function: NORMAL (SIGMA)
          Equivalent to RV.NORMAL(0, SIGMA).

 -- Function: PDF.NTAIL (X, A, SIGMA)
 -- Function: RV.NTAIL (A, SIGMA)
     Normal tail distribution with lower limit A and standard deviation SIGMA.  This distribution is a pspp extension. Constraints: A > 0, X > A, 0 < P < 1.

 -- Function: PDF.PARETO (X, A, B)
 -- Function: CDF.PARETO (X, A, B)
 -- Function: IDF.PARETO (P, A, B)
 -- Function: RV.PARETO (A, B)
     Pareto distribution with threshold parameter A and shape parameter B.  Constraints: A > 0, B > 0, X >= A, 0 <= P < 1.

 -- Function: PDF.RAYLEIGH (X, SIGMA)
 -- Function: CDF.RAYLEIGH (X, SIGMA)
 -- Function: IDF.RAYLEIGH (P, SIGMA)
 -- Function: RV.RAYLEIGH (SIGMA)
     Rayleigh distribution with scale parameter SIGMA.  This distribution is a pspp extension.  Constraints: SIGMA > 0, X > 0.

 -- Function: PDF.RTAIL (X, A, SIGMA)
 -- Function: RV.RTAIL (A, SIGMA)
     Rayleigh tail distribution with lower limit A and scale parameter SIGMA.  This distribution is a pspp extension. Constraints: A > 0, SIGMA > 0, X > A.

 -- Function: PDF.T (X, DF)
 -- Function: CDF.T (X, DF)
 -- Function: IDF.T (P, DF)
 -- Function: RV.T (DF)
     T-distribution with DF degrees of freedom.  The noncentral distribution takes an additional parameter LAMBDA.  Constraints: DF > 0, 0 < P < 1.

 -- Function: PDF.T1G (X, A, B)
 -- Function: CDF.T1G (X, A, B)
 -- Function: IDF.T1G (P, A, B)
     Type-1 Gumbel distribution with parameters A and B.  This distribution is a pspp extension.  Constraints: 0 < P < 1.

 -- Function: PDF.T2G (X, A, B)
 -- Function: CDF.T2G (X, A, B)
 -- Function: IDF.T2G (P, A, B)
     Type-2 Gumbel distribution with parameters A and B.  This distribution is a pspp extension.  Constraints: X > 0, 0 < P < 1.

 -- Function: PDF.UNIFORM (X, A, B)
 -- Function: CDF.UNIFORM (X, A, B)
 -- Function: IDF.UNIFORM (P, A, B)
 -- Function: RV.UNIFORM (A, B)
     Uniform distribution with parameters A and B. Constraints: A <= X <= B, 0 <= P <= 1.  An additional function is available as shorthand:

      -- Function: UNIFORM (B)
          Equivalent to RV.UNIFORM(0, B).

 -- Function: PDF.WEIBULL (X, A, B)
 -- Function: CDF.WEIBULL (X, A, B)
 -- Function: IDF.WEIBULL (P, A, B)
 -- Function: RV.WEIBULL (A, B)
     Weibull distribution with parameters A and B. Constraints: A > 0, B > 0, X >= 0, 0 <= P < 1.

Discrete Distributions
......................

The following discrete distributions are available:

 -- Function: PDF.BERNOULLI (X)
 -- Function: CDF.BERNOULLI (X, P)
 -- Function: RV.BERNOULLI (P)
     Bernoulli distribution with probability of success P. Constraints: X = 0 or 1, 0 <= P <= 1.

 -- Function: PDF.BINOMIAL (X, N, P)
 -- Function: CDF.BINOMIAL (X, N, P)
 -- Function: RV.BINOMIAL (N, P)
     Binomial distribution with N trials and probability of success P.  Constraints: integer N > 0, 0 <= P <= 1, integer X <= N.

 -- Function: PDF.GEOM (X, N, P)
 -- Function: CDF.GEOM (X, N, P)
 -- Function: RV.GEOM (N, P)
     Geometric distribution with probability of success P. Constraints: 0 <= P <= 1, integer X > 0.

 -- Function: PDF.HYPER (X, A, B, C)
 -- Function: CDF.HYPER (X, A, B, C)
 -- Function: RV.HYPER (A, B, C)
     Hypergeometric distribution when B objects out of A are drawn and C of the available objects are distinctive. Constraints: integer A > 0, integer B <= A, integer C <= A, integer X >= 0.

 -- Function: PDF.LOG (X, P)
 -- Function: RV.LOG (P)
     Logarithmic distribution with probability parameter P. Constraints: 0 <= P < 1, X >= 1.

 -- Function: PDF.NEGBIN (X, N, P)
 -- Function: CDF.NEGBIN (X, N, P)
 -- Function: RV.NEGBIN (N, P)
     Negative binomial distribution with number of successes parameter N and probability of success parameter P.  Constraints: integer N >= 0, 0 < P <= 1, integer X >= 1.

 -- Function: PDF.POISSON (X, MU)
 -- Function: CDF.POISSON (X, MU)
 -- Function: RV.POISSON (MU)
     Poisson distribution with mean MU.  Constraints: MU > 0, integer X >= 0.

Operator Precedence
===================

The following table describes operator precedence.  Smaller-numbered levels in the table have higher precedence.  Within a level, operations are always performed from left to right.  The first occurrence of - represents unary negation, the second binary subtraction.

 1. (  )

 2. **

 3. -

 4. *  /

 5. +  -

 6. EQ  GE  GT  LE  LT  NE

 7. AND  NOT  OR