Element List Syntax

The Table and Axis Syntax topic describes the syntax that you use to define the axes of your tables. One of the options is to use an element list to specify the elements that are to be included.

The term element includes categories, user-defined categories, means or other statistics, and any other item that forms part of a variable (in the IBM® SPSS® Data Collection Survey Reporter user interface, the term category is used to refer to all of these items for the sake of simplicity, but strictly speaking they are elements). Each element is usually displayed as a row or column on a table (though in some cases the element may be included in the table but not displayed).

The element list syntax is:

VariableName {<Element-List>}

<Element-List>  ::=   <Element> (, <Element>)*  

<Element>       ::=   [^] ElementName ['Label-text'] [<Properties>]
                    | ElementName ([LanguageID: 'Label-text'])*
                    | [^] [ElementName] .. [ElementName] 
                    | <Special-Element>
PartDescription
VariableName The name of a variable in the metadata.
ElementName The name of an element in the specified variable.
^ Indicates that the following item is to be excluded.
.. Indicates a range of elements.
LanguageID The code of a language that exists in the metadata. For details of recognized language codes, see Languages (3-Character Codes).
<Special-Element>Defines a special non-category element. See the topic Element Syntax for more information.
<Properties>Defines one or more properties for the element. See the topic Element Property Syntax for more information.

The list of elements is evaluated from left to right and determines the order in which the elements appear in the axis.

Element Names

Do not use the default names of special elements as element names unless you are creating a special element. If you are creating multiple elements, ensure that the element names are unique.

Examples

The following examples are based on the interest variable in the Museum sample data set. The interest variable has the following elements:

PositionElement Name
1Dinosaurs
2Conservation
3Fish_and_reptiles
4Fossils
5Birds
6Insects
7Whales
8Mammals
9Minerals
10Ecology
11Botany
12Origin_of_species
13Human_biology
14Evolution
15Wildlife_in_danger
16Other
17Not_answered

1. Single elements

interest{Whales, Fossils, Dinosaurs} 

This creates an axis that has three elements from the interest variable in the order Whales, Fossils, Dinosaurs.

2. All elements from the first to a specified element

interest{.. Whales}  

This creates an axis that has a range of elements from the first element in the variable's element list through the Whales element (which in this example is the seventh element in the variable). The elements appear in the order in which they appear in the variable (Dinosaurs, Conservation, Fish_and_reptiles, Fossils, Birds, Insects, Whales).

3. All elements from a specified element to the last element

interest{Whales..}  

This creates an axis that has a range of elements from the Whales element through the last element in the variable's element list. The elements appear in the order in which they appear in the variable (Whales, Mammals, Minerals, Ecology, Botany, Origin_of_species, Human_biology, Evolution, Wildlife_in_danger, Other, Not_answered).

4. A range of elements

interest{Whales..Botany}   

This creates an axis that has an element list starting with the Whales element and ending with the Botany element and including all of the elements in between (Whales, Mammals, Minerals, Ecology, Botany).

5. All elements

interest{..}   

This creates an axis that has all of the elements in the variable in their default order. Although this syntax is not generally used on its own, it is useful when you want to exclude categories from the list as shown in the next example, or add special elements to the list of elements. See the topic Element Syntax for more information.

6. All elements except those in a specified range

interest{.., ^Other..Not_answered}   

This creates an axis that has all of the elements in the variable in their default order with the exception of any elements in the list from Other through Not_answered. (The elements that are included are Dinosaurs, Conservation, Fish_and_reptiles, Fossils, Birds, Insects, Whales, Mammals, Minerals, Ecology, Botany, Origin_of_species, Human_biology, Evolution, and Wildlife_in_danger.)

7. All elements in a range with the exception of one specified element

interest{Dinosaurs..Whales, ^Conservation}    

This creates an axis that has all of the elements in the variable from Dinosaurs through Whales with the exception of the Conservation element. (The elements that are included are Dinosaurs, Fish_and_reptiles, Fossils, Birds, Insects, and Whales.)

8. Specified elements using custom labels

interest{Dinosaurs 'Extinct reptiles', Whales 'Large marine mammals'}     

This creates an axis that has two elements (Dinosaurs and Whales). However, instead of using the standard labels stored in the metadata for the current language, user context, and label type, the elements will have labels of Extinct reptiles and Large marine mammals, respectively. These custom labels will be used for the current language, user context, and label type only. If you change the language, user context, or label type, the label stored in the metadata for the selected language, user context and label type will be used. However, if you return to the original language, user context, and label type, the custom labels will be used again.

When you specify a custom label, you need to enclose the label text in single quotation marks ('<label text>') or two double quotation marks (""<label text>""). If you use single quotation marks, you must escape any single or double quotation marks included in the label with a second quotation mark of the same type. This indicates that the quotation mark used in the label does not represent the end of the label. If you use two double quotation marks, you need to escape any double quotation marks used in the label with three double quotation marks.

9. Custom labels in multiple languages

interest{Dinosaurs ENU:'Extinct reptiles' ESN:'Reptiles extintos',  
   Whales ENU:'Large marine mammals'  ESN:'Mamíferos marinos grandes'}     

This creates an axis that has the same two elements (Dinosaurs and Whales) as in the previous example. However, this time custom labels have been defined for two languages (ENU--United States English and ESN--International Spanish). These labels will be used for the specified languages only and if you select another language, the label stored in the metadata for that language will be used.