Chapter 7: Mathematical Expressions
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.
Returns date advanced by the given quantity of the speciﬁed unit, which must be
one of the strings ‘years’, ‘quarters’, ‘months’, ‘weeks’, ‘days’, ‘hours’, ‘minutes’,
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 speciﬁed as ‘closest’ (as a quoted string), then the resulting day is the
last day of the month; otherwise, if it is speciﬁed 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 speciﬁed, is ignored.
7.7.9 Miscellaneous Functions
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 ﬁrst 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
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 ﬁrst month of the
next year. year must be in range. year, month, and day must all be integers.