This part of the Command Syntax Reference discusses general topics pertinent to using command
syntax. The topics are divided into five sections:Commands explains command syntax, including command specification, command order,and running commands in different modes. In this section, you will learn how to read syntax charts, which summarize command syntax in diagrams and provide an easy reference.
Discussions of individual commands are found in an alphabetical reference in the next part of this manual.
Files discusses different types of files used by the program. Terms frequently mentioned in this manual are defined. This section provides an overview of how files are handled.
Variables and Variable Types and Formats contain important information about general rules and conventions regarding variables and variable definition.Transformations describes expressions that can be used in data transformation. Functionsand operators are defined and illustrated. In this section, you will find a complete list of available functions and how to use them.Commands Commands are the instructions that you give the program to initiate an action. For the program to interpret your commands correctly, you must follow certain rules.
Syntax Diagrams
Each command described in this manual includes a syntax diagram that shows all of the subcommands, keywords, and specifications allowed for that command. By recognizing symbols and different type fonts, you can use the syntax diagram as a quick reference for any command. Lines of text in italics indicate limitation or operation mode of the command. Elements shown in upper case are keywords to identify commands, subcommands, functions, operators, and other specifications. In the sample syntax diagram below, T-TEST is the command and GROUPS is a subcommand.
Elements in lower case describe specifications that you supply. For example, varlist indicates that you need to supply a list of variables.Elements in bold are defaults. There are two types of defaults. When thedefault is followed by **, as ANALYSIS** is in the sample syntax diagram below, the default (ANALYSIS) is in
effect if the subcommand (MISSING) is not specified. If a default is not followed by **, it is in effect when the subcommand (or keyword) is specified by itself. Parentheses, apostrophes, and quotation marks are required where indicated.
Unless otherwise noted, elements enclosed in square brackets ([ ]) are optional. For some
commands, square brackets are part of the required syntax. The command description
explains which specifications are required and which are optional.
Braces ({ }) indicate a choice between elements. You can specify any one of the elements enclosed within the aligned braces. Ellipses indicate that you can repeat an element in the specification. The specification
T-TEST PAIRS=varlist [WITH varlist [(PAIRED)]] [/varlist ...]
means that you can specify multiple variable lists with optional WITH variables and the keyword PAIRED in parentheses. Most abbreviations are obvious; for example, varname stands for variable name and varlist stands for a variable list. The command terminator is not shown in the syntax diagram.
SPSS reads, creates, and writes different types of files. This section provides an overview of these
types and discusses concepts and rules that apply to all files.
Command File
A command file is a text file that contains syntax commands. You can type commands in a
syntax window in an interactive session, use the Paste button in dialog boxes to paste generated
commands into a syntax window, and/or use any text editor to create a command file. You can also
edit a journal file to produce a command file. For more information, see Journal File on p. 40. The
following is an example of a simple command file that contains both commands and inline data:
Case does not matter for commands but is significant for inline data. If you specified f for
female and m for male in column 4 of the data line, the value of Gender would be f or
m instead of F or M as it is now.
Commands can be in upper or lower case. Uppercase characters are used for all commands
throughout this manual only to distinguish them from other text.
Journal File
SPSS keeps a journal file to record all commands either run from a syntax window or generated
from a dialog box during a session. You can retrieve this file with any text editor and review it to
learn how the session went. You can also edit the file to build a new command file and use it in
another run. An edited and tested journal file can be saved and used later for repeated tasks. The
journal file also records any error or warning messages generated by commands. You can rerun
these commands after making corrections and removing the messages.
41
Universals
The journal file is controlled by the File Locations tab of the Options dialog box, available from
the Edit menu. You can turn journaling off and on, append or overwrite the journal file, and select
the journal filename and location. By default, commands from subsequent sessions are appended
to the journal, and the default journal filename is spss.jnl.
The following example is a journal file for a short session with a warning message.
Case does not matter for commands but is significant for inline data. If you specified f for
female and m for male in column 4 of the data line, the value of Gender would be f or
m instead of F or M as it is now.
Commands can be in upper or lower case. Uppercase characters are used for all commands
throughout this manual only to distinguish them from other text.
Journal File
SPSS keeps a journal file to record all commands either run from a syntax window or generated
from a dialog box during a session. You can retrieve this file with any text editor and review it to
learn how the session went. You can also edit the file to build a new command file and use it in
another run. An edited and tested journal file can be saved and used later for repeated tasks. The
journal file also records any error or warning messages generated by commands. You can rerun
these commands after making corrections and removing the messages.
41
Universals
The journal file is controlled by the File Locations tab of the Options dialog box, available from
the Edit menu. You can turn journaling off and on, append or overwrite the journal file, and select
the journal filename and location. By default, commands from subsequent sessions are appended
to the journal, and the default journal filename is spss.jnl.
The following example is a journal file for a short session with a warning message.
An SPSS-format data file is a file specifically formatted for use by SPSS, containing both data and
the metadata (dictionary) that define the data.
To save the active dataset in SPSS format, use SAVE or XSAVE. On most operating systems,
the default extension of a saved SPSS-format data file is .sav. An SPSS-format data file can
also be a matrix file created with the MATRIX=OUT subcommand on procedures that write
matrices.
To open an SPSS-format data file, use GET.
SPSS Data File Structure
The basic structure of an SPSS data file is similar to a database table:
Rows (records) are cases. Each row represents a case or an observation. For example, each
individual respondent to a questionnaire is a case.
Columns (fields) are variables. Each column represents a variable or characteristic that is
being measured. For example, each item on a questionnaire is a variable.
An SPSS data file also contains metadata that describes and defines the data contained in the
file. This descriptive information is called the dictionary. The information contained in the
dictionary includes:
Variable names and descriptive variable labels (VARIABLE LABELS command).
Descriptive values labels (VALUE LABELS command).
Missing values definitions (MISSING VALUES command).
Print and write formats (FORMATS command).
Use DISPLAY DICTIONARY to display the dictionary for the active dataset. For more
information, see DISPLAY on p. 598.You can also use SYSFILE INFO to display dictionary
information for any SPSS-format data file.
43
Universals
Long Variable Names
In some instances, data files with variable names longer than eight bytes require special
consideration:
If you save a data file in portable format (see EXPORT on p. 640), variable names that exceed
eight bytes are converted to unique eight-character names. For example, mylongrootname1,
mylongrootname2, and mylongrootname3 would be converted to mylongro, mylong_2, and
mylong_3, respectively.
When using data files with variable names longer than eight bytes in version 10.x or 11.x,
unique, eight-byte versions of variable names are used; however, the original variable names
are preserved for use in release 12.0 or later. In releases prior to 10.0, the original long
variable names are lost if you save the data file.
Matrix data files (commonly created with the MATRIX OUT subcommand, available in some
procedures) in which the VARNAME_ variable is longer than an eight-byte string cannot
be read by releases prior to 12.0.
syntax. The topics are divided into five sections:Commands explains command syntax, including command specification, command order,and running commands in different modes. In this section, you will learn how to read syntax charts, which summarize command syntax in diagrams and provide an easy reference.
Discussions of individual commands are found in an alphabetical reference in the next part of this manual.
Files discusses different types of files used by the program. Terms frequently mentioned in this manual are defined. This section provides an overview of how files are handled.
Variables and Variable Types and Formats contain important information about general rules and conventions regarding variables and variable definition.Transformations describes expressions that can be used in data transformation. Functionsand operators are defined and illustrated. In this section, you will find a complete list of available functions and how to use them.Commands Commands are the instructions that you give the program to initiate an action. For the program to interpret your commands correctly, you must follow certain rules.
Syntax Diagrams
Each command described in this manual includes a syntax diagram that shows all of the subcommands, keywords, and specifications allowed for that command. By recognizing symbols and different type fonts, you can use the syntax diagram as a quick reference for any command. Lines of text in italics indicate limitation or operation mode of the command. Elements shown in upper case are keywords to identify commands, subcommands, functions, operators, and other specifications. In the sample syntax diagram below, T-TEST is the command and GROUPS is a subcommand.
Elements in lower case describe specifications that you supply. For example, varlist indicates that you need to supply a list of variables.Elements in bold are defaults. There are two types of defaults. When thedefault is followed by **, as ANALYSIS** is in the sample syntax diagram below, the default (ANALYSIS) is in
effect if the subcommand (MISSING) is not specified. If a default is not followed by **, it is in effect when the subcommand (or keyword) is specified by itself. Parentheses, apostrophes, and quotation marks are required where indicated.
Unless otherwise noted, elements enclosed in square brackets ([ ]) are optional. For some
commands, square brackets are part of the required syntax. The command description
explains which specifications are required and which are optional.
Braces ({ }) indicate a choice between elements. You can specify any one of the elements enclosed within the aligned braces. Ellipses indicate that you can repeat an element in the specification. The specification
T-TEST PAIRS=varlist [WITH varlist [(PAIRED)]] [/varlist ...]
means that you can specify multiple variable lists with optional WITH variables and the keyword PAIRED in parentheses. Most abbreviations are obvious; for example, varname stands for variable name and varlist stands for a variable list. The command terminator is not shown in the syntax diagram.
SPSS reads, creates, and writes different types of files. This section provides an overview of these
types and discusses concepts and rules that apply to all files.
Command File
A command file is a text file that contains syntax commands. You can type commands in a
syntax window in an interactive session, use the Paste button in dialog boxes to paste generated
commands into a syntax window, and/or use any text editor to create a command file. You can also
edit a journal file to produce a command file. For more information, see Journal File on p. 40. The
following is an example of a simple command file that contains both commands and inline data:
Case does not matter for commands but is significant for inline data. If you specified f for
female and m for male in column 4 of the data line, the value of Gender would be f or
m instead of F or M as it is now.
Commands can be in upper or lower case. Uppercase characters are used for all commands
throughout this manual only to distinguish them from other text.
Journal File
SPSS keeps a journal file to record all commands either run from a syntax window or generated
from a dialog box during a session. You can retrieve this file with any text editor and review it to
learn how the session went. You can also edit the file to build a new command file and use it in
another run. An edited and tested journal file can be saved and used later for repeated tasks. The
journal file also records any error or warning messages generated by commands. You can rerun
these commands after making corrections and removing the messages.
41
Universals
The journal file is controlled by the File Locations tab of the Options dialog box, available from
the Edit menu. You can turn journaling off and on, append or overwrite the journal file, and select
the journal filename and location. By default, commands from subsequent sessions are appended
to the journal, and the default journal filename is spss.jnl.
The following example is a journal file for a short session with a warning message.
Case does not matter for commands but is significant for inline data. If you specified f for
female and m for male in column 4 of the data line, the value of Gender would be f or
m instead of F or M as it is now.
Commands can be in upper or lower case. Uppercase characters are used for all commands
throughout this manual only to distinguish them from other text.
Journal File
SPSS keeps a journal file to record all commands either run from a syntax window or generated
from a dialog box during a session. You can retrieve this file with any text editor and review it to
learn how the session went. You can also edit the file to build a new command file and use it in
another run. An edited and tested journal file can be saved and used later for repeated tasks. The
journal file also records any error or warning messages generated by commands. You can rerun
these commands after making corrections and removing the messages.
41
Universals
The journal file is controlled by the File Locations tab of the Options dialog box, available from
the Edit menu. You can turn journaling off and on, append or overwrite the journal file, and select
the journal filename and location. By default, commands from subsequent sessions are appended
to the journal, and the default journal filename is spss.jnl.
The following example is a journal file for a short session with a warning message.
An SPSS-format data file is a file specifically formatted for use by SPSS, containing both data and
the metadata (dictionary) that define the data.
To save the active dataset in SPSS format, use SAVE or XSAVE. On most operating systems,
the default extension of a saved SPSS-format data file is .sav. An SPSS-format data file can
also be a matrix file created with the MATRIX=OUT subcommand on procedures that write
matrices.
To open an SPSS-format data file, use GET.
SPSS Data File Structure
The basic structure of an SPSS data file is similar to a database table:
Rows (records) are cases. Each row represents a case or an observation. For example, each
individual respondent to a questionnaire is a case.
Columns (fields) are variables. Each column represents a variable or characteristic that is
being measured. For example, each item on a questionnaire is a variable.
An SPSS data file also contains metadata that describes and defines the data contained in the
file. This descriptive information is called the dictionary. The information contained in the
dictionary includes:
Variable names and descriptive variable labels (VARIABLE LABELS command).
Descriptive values labels (VALUE LABELS command).
Missing values definitions (MISSING VALUES command).
Print and write formats (FORMATS command).
Use DISPLAY DICTIONARY to display the dictionary for the active dataset. For more
information, see DISPLAY on p. 598.You can also use SYSFILE INFO to display dictionary
information for any SPSS-format data file.
43
Universals
Long Variable Names
In some instances, data files with variable names longer than eight bytes require special
consideration:
If you save a data file in portable format (see EXPORT on p. 640), variable names that exceed
eight bytes are converted to unique eight-character names. For example, mylongrootname1,
mylongrootname2, and mylongrootname3 would be converted to mylongro, mylong_2, and
mylong_3, respectively.
When using data files with variable names longer than eight bytes in version 10.x or 11.x,
unique, eight-byte versions of variable names are used; however, the original variable names
are preserved for use in release 12.0 or later. In releases prior to 10.0, the original long
variable names are lost if you save the data file.
Matrix data files (commonly created with the MATRIX OUT subcommand, available in some
procedures) in which the VARNAME_ variable is longer than an eight-byte string cannot
be read by releases prior to 12.0.