Overview (VARIABLE ATTRIBUTE command)
VARIABLE ATTRIBUTE
provides you with the ability
to define your own variable attributes and assign attribute values
to variables in the active dataset. For example, you could create
a variable attribute that identifies the type of response for survey
questions (e.g., single selection, multiple selection, fill-in-the-blank)
or the formulas used for computed variables.
- User-defined variable attributes are saved with the data file in the data dictionary.
- The
VARIABLE ATTRIBUTE
command takes effect immediately, updating the data dictionary without requiring a data pass. - You can display a list of data file and variable attributes with
DISPLAY ATTRIBUTES
. See the topic DISPLAY for more information.
Basic Specification
The basic specification is:
- The
VARIABLES
subcommand followed by an equals sign (=) and a list of valid variables. - The
ATTRIBUTE
keyword followed by an equals sign (=) and one or more attribute names that follow variable naming rules, with each attribute name followed by a quoted attribute value enclosed in parentheses.
or
- The
DELETE
keyword followed by an equals sign (=) and a list of defined attribute names or attribute arrays.
Syntax Rules
- The
VARIABLES
subcommand is required. - All subcommands and keywords (
VARIABLES
,ATTRIBUTE
,DELETE
) must be followed by an equals sign (=). - Each
ATTRIBUTE
keyword must be followed by a name that follows variable naming rules and a single, quoted attribute value enclosed in parentheses. See the topic Variable Names for more information. - Attribute names that begin with @ cannot be displayed in Variable
View of the Data Editor and are not displayed by
DISPLAY DICTIONARY
orDISPLAY ATTRIBUTES
. They can only be displayed withDISPLAY @ATTRIBUTES
. - Attribute names that begin with a dollar sign ($) are reserved for internal IBM® SPSS® Statistics use.
- All attribute values must be quoted (single or double quotes), even if the values are numbers.
- Attribute values can be up to 32,767 bytes in length.
Attribute Arrays
If you append an integer enclosed in square brackets to the end of an attribute name, the attribute is interpreted as an array of attributes. For example,
VARIABLE ATTRIBUTE VARIABLES=Age
ATTRIBUTE=MyAttribute[99]('not quite 100').
will create 99 attributes--MyAttribute[01] through MyAttribute[99]--and will assign the value "not quite 100" to the last one.
- Array subscripts (the value enclosed in square brackets) must be integers greater than 0. (Array subscript numbering starts with 1, not 0.)
- If the root name of an attribute array is the same as an existing
attribute name for any variables specified on the
VARIABLES
subcommand, the attribute array replaces the existing attribute for those variables (and vice versa). If no value is assigned to the first element in the array (subscript [1]), the original attribute value is used for that element value.
With the DELETE
keyword, the following rules apply
to attribute arrays:
- If you specify
DELETE
followed by an array rootname and no value in square brackets, all attributes in the array are deleted. - If you specify
DELETE
with an array name followed by an integer value in square brackets, the specified array element is deleted and the integer values for all subsequent attributes in the array (in numeric order) are changed to reflect the new order of array elements.