@cindex cross-case function
@cindex function, cross-case
@deftypefn {Function} {} LAG (@var{variable})
+@anchor{LAG}
@var{variable} must be a numeric or string variable name. @code{LAG}
results in the value of that variable for the case before the current
one. In case-selection procedures, @code{LAG} results in the value of
variables are combined into a single record. Records with different
values are output in order. Thus, multiple sorted system files are
combined into a single sorted system file based on the value of the BY
-variables.
+variables. The results of the merge become the new active file.
The BY subcommand specifies a list of variables that are used to match
records from each of the system files. Variables specified must exist
IN, FIRST, LAST, and MAP are currently not used.
+@cmd{MATCH FILES} may not be specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}) if the active file is used as an input source.
+
@node SAVE, SYSFILE INFO, MATCH FILES, System and Portable Files
@section SAVE
@vindex SAVE
If either DROP or KEEP is specified, the data is read; otherwise it is
not.
+@cmd{MODIFY VARS} may not be specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}).
+
@node NUMERIC, PRINT FORMATS, MODIFY VARS, Variable Attributes
@section NUMERIC
@vindex NUMERIC
@cmd{RENAME VARIABLES} takes effect immediately. It does not cause the data
to be read.
+@cmd{RENAME VARIABLES} may not be specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}).
+
@node VALUE LABELS, STRING, RENAME VARIABLES, Variable Attributes
@section VALUE LABELS
@vindex VALUE LABELS
(@pxref{LEAVE}) resets the variable's left state. Therefore,
@code{LEAVE} should be specified following @cmd{COMPUTE}, not before.
-COMPUTE is a transformation. It does not cause the active file to be
+@cmd{COMPUTE} is a transformation. It does not cause the active file to be
read.
+When @cmd{COMPUTE} is specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
+(@pxref{LAG}).
+
@node COUNT, FLIP, COMPUTE, Data Manipulation
@section COUNT
@vindex COUNT
variable can
be used to recreate the original variable names.
+FLIP honors N OF CASES. It ignores TEMPORARY, so that ``temporary''
+transformations become permanent.
+
@node IF, RECODE, FLIP, Data Manipulation
@section IF
@vindex IF
(@pxref{LEAVE}) resets the variable's left state. Therefore,
@code{LEAVE} should be specified following @cmd{IF}, not before.
+When @cmd{IF} is specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
+(@pxref{LAG}).
+
@node RECODE, SORT CASES, IF, Data Manipulation
@section RECODE
@vindex RECODE
@cmd{SORT CASES} attempts to sort the entire active file in main memory.
If main memory is exhausted, it falls back to a merge sort algorithm that
-involves writing and reading numerous temporary files. Environment
-variables determine the temporary files' location. The first of
-SPSSTMPDIR, SPSSXTMPDIR, or TMPDIR that is set determines the location.
-Otherwise, if the compiler environment defined P_tmpdir, that is used.
-Otherwise, under Unix-like OSes /tmp is used; under MS-DOS, the first of
-TEMP, TMP, or root on the current drive is used; under other OSes, the
-current directory.
+involves writing and reading numerous temporary files.
+
+@cmd{SORT CASES} may not be specified following TEMPORARY.
@node Data Selection, Conditionals and Looping, Data Manipulation, Top
@chapter Selecting data for analysis
BY is optional but recommended. Cases which have a zero or system- or
user-missing value are excluded from analysis, but not deleted from the
data stream. Cases with other values are analyzed.
+To filter based on a different condition, use
+transformations such as @cmd{COMPUTE} or @cmd{RECODE} to compute a
+filter variable of the required form, then specify that variable on
+@cmd{FILTER}.
@code{FILTER OFF} turns off case filtering.
Filtering takes place immediately before cases pass to a procedure for
analysis. Only one filter variable may be active at a time. Normally,
case filtering continues until it is explicitly turned off with @code{FILTER
-OFF}. However, if @cmd{FILTER} is placed after TEMPORARY, filtering stops
-after execution of the next procedure or procedure-like command.
+OFF}. However, if @cmd{FILTER} is placed after TEMPORARY, it filters only
+the next procedure or procedure-like command.
@node N OF CASES, PROCESS IF, FILTER, Data Selection
@section N OF CASES
processed by procedures. PSPP currently does not make use of
case count estimates.
+When @cmd{N} is specified after @cmd{TEMPORARY}, it affects only
+the next procedure (@pxref{TEMPORARY}).
+
@node PROCESS IF, SAMPLE, N OF CASES, Data Selection
@section PROCESS IF
@vindex PROCESS IF
effects of executing @cmd{TEMPORARY}, then @cmd{SELECT IF}
(@pxref{SELECT IF}).
+The filtering performed by @cmd{PROCESS IF} takes place immediately
+before cases pass to a procedure for analysis. Because @cmd{PROCESS
+IF} affects only a single procedure, its placement relative to
+@cmd{TEMPORARY} is unimportant.
+
@cmd{PROCESS IF} is deprecated. It is included for compatibility with
old command files. New syntax files should use @cmd{SELECT IF} or
@cmd{FILTER} instead.
SAMPLE num1 [FROM num2].
@end display
-@cmd{SAMPLE} is used to randomly sample a proportion of the cases in
-the active file. @cmd{SAMPLE} is temporary, affecting only the next
-procedure, unless that is a data transformation, such as @cmd{SELECT IF}
-or @cmd{RECODE}.
+@cmd{SAMPLE} randomly samples a proportion of the cases in the active
+file. Unless it follows @cmd{TEMPORARY}, it operates as a
+transformation, permanently removing cases from the active file.
The proportion to sample can be expressed as a single number between 0
and 1. If @code{k} is the number specified, and @code{N} is the number
@var{N} cases in the active file.}
@end enumerate
-@cmd{SAMPLE}, @cmd{SELECT IF}, and @code{PROCESS IF} are performed in
+@cmd{SAMPLE} and @cmd{SELECT IF} are performed in
the order specified by the syntax file.
-@cmd{SAMPLE} is ignored before @code{SORT CASES}.
-
@cmd{SAMPLE} is always performed before @code{N OF CASES}, regardless
-of ordering in the syntax file. @xref{N OF CASES}.
+of ordering in the syntax file (@pxref{N OF CASES}).
The same values for @cmd{SAMPLE} may result in different samples. To
obtain the same sample, use the @code{SET} command to set the random
possible. Cases that are deleted early can be processed more
efficiently in time and space.
+When @cmd{SELECT IF} is specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
+(@pxref{LAG}).
+
@node SPLIT FILE, TEMPORARY, SELECT IF, Data Selection
@section SPLIT FILE
@vindex SPLIT FILE
Specify OFF to disable @cmd{SPLIT FILE} and resume analysis of the
entire active file as a single group of data.
+When @cmd{SPLIT FILE} is specified after @cmd{TEMPORARY}, it affects only
+the next procedure (@pxref{TEMPORARY}).
+
@node TEMPORARY, WEIGHT, SPLIT FILE, Data Selection
@section TEMPORARY
@vindex TEMPORARY
affect only the execution of the next procedure or procedure-like
command. Their effects will not be saved to the active file.
-The only specification is the command name.
+The only specification on @cmd{TEMPORARY} is the command name.
@cmd{TEMPORARY} may not appear within a @cmd{DO IF} or @cmd{LOOP}
-construct. It may
-appear only once between procedures and procedure-like commands.
+construct. It may appear only once between procedures and
+procedure-like commands.
+
+Scratch variables cannot be used following @cmd{TEMPORARY}.
An example may help to clarify:
variable are interpreted as weighting factors of 0. User-missing
values are not treated specially.
+When @cmd{WEIGHT} is specified after @cmd{TEMPORARY}, it affects only
+the next procedure (@pxref{TEMPORARY}).
+
@cmd{WEIGHT} does not cause cases in the active file to be replicated in
memory.
turn, with the same rules applied. If all expressions evaluate to
false, then the @cmd{ELSE} code block is executed, if it is present.
+When @cmd{DO IF} or @cmd{ELSE IF} is specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
+(@pxref{LAG}).
+
@node DO REPEAT, LOOP, DO IF, Conditionals and Looping
@section DO REPEAT
@vindex DO REPEAT
@cmd{BREAK} also terminates @cmd{LOOP} execution (@pxref{BREAK}).
+When @cmd{LOOP} or @cmd{END LOOP} is specified following @cmd{TEMPORARY}
+(@pxref{TEMPORARY}), the @cmd{LAG} function may not be used
+(@pxref{LAG}).
+
@node Statistics, Utilities, Conditionals and Looping, Top
@chapter Statistics