From SPSS For Dummies, 2nd Edition by Arthur Griffith
SPSS is an application that performs statistical analysis on data. Entering and manipulating information in the application can be done by using SPSS’s proprietary language, which is known as the Syntax command language, or more commonly, as Syntax. The language is quite like other programming languages, and it allows you to define variables (or use predefined ones), and to use them within statements, or to evaluate them with relational or logical operators. Good programmers always know to make their code accessible through the use of comments. Syntax can also be used in conjunction with Basic and Python.
SPSS Syntax Language Variable Definitions
In Syntax, you can define several different characteristics for each of your variables. Here is the full collection of possibilities among SPSS Syntax language variables:
Short form of the variable name
Numeric, comma, dot, scientific notation, date, dollar, custom currency, or string
Maximum number of characters used to display the data
Number of digits to the right of the decimal point
Long form of the variable name
Names assigned to specific values
Value, or values, to represent missing values
Number of spaces into which the value is displayed
Right, left, or center
Scale, ordinal, or nominal
Input, target, both, none, partition, or split
SPSS Syntax Language Statements
A single Syntax language instruction can be very simple, or it can be complex enough to serve as an entire program. A single instruction consists of a command followed by arguments to modify or expand the actions of the command, as follows:
Every statement begins with a command.
Each command has a specific set of options
The value, or values, for the option.
Every statement ends with a period as a terminator.
SPSS Syntax Language Predefined Variables
Most of the values used in Syntax are from the variables in the data set you currently have loaded and displayed in SPSS. You simply use your variable names in your program, and SPSS knows where to go and get the values for it.
Some other variables are already defined, and you can use them anywhere in a program. Predefined variables, which are called system variables, all begin with a dollar sign ($) and already contain values
The system variables are listed in the table below:
||What It Is
||Current case number. It is the count of cases from the beginning to the current one.
||Current date in international format with two-digit year.
||Current date in international format with four-digit year.
||Count of the number of days since October 14, 1582 (the first day of the Gregorian calendar).
||Current page length.
||System missing value. This prints as a period (.) or whatever is defined as the decimal point.
||Number of seconds since midnight October 14, 1582 (the first day of the Gregorian calendar).
||Current page width.
SPSS Syntax Language Comments
You can insert descriptive text, called a comment, into your program. This text doesn’t do anything except help make things clear when you read (or somebody else reads) your code. You start a comment the same way you start any other command: on its own line by using the keyword COMMENT or an asterisk or an asterisk-slash. The comment is terminated by a period. For example:
COMMENT This is a comment and will not be executed. * This is a comment and will continue to be a comment until the terminating period. /* This is a comment and will continue to be a comment until the terminating asterisk-slash */
SSPS Syntax Language Relational Operators
Syntax offers conditional statements that are executed only if conditions are right. Usually those conditions are determined by evaluating the contents of a variable with a logical or relational operator. The following table lists the relational operators you can use to compare numbers:
||What It Is
||Is equal to
||Is less than
||Is greter than
||Is not equal to
||Is less than or equal to
||Is greater than or equal to
SPSS Syntax Language Logical Operators
Syntax offers conditional statements that are executed only if conditions are right. Usually those conditions are determined by evaluating the contents of a variable with a logical or relational operator. The following table lists the logical operators you can use for longer, complex comparisons:
||Both relational operators must be true
||Either relational operator can be true
||Reverses the result of a relational operator