Server User Guides > Survey Tabulation > Table specification syntax > Element list syntax
 
Element list syntax
Table and axis syntax in scripts 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 UNICOM Intelligence Reporter - Survey Tabulation 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 might be included in the table but not displayed).
Element list syntax
<variable_name>
{<element_list>}
<element-list> ::= <element> (, <element>)*
<element> ::= [^] <element_name> ['<label-text>'] [<properties>]
             | <element_name> ([<language_id>: '<label-text>'])*
             | [^] [<element_name>] .. [<element_name>]
             | <special_element>
Parts
<variable_name>
The name of a variable in the metadata.
<element_name>
The name of an element in the specified variable.
^
Excludes the following item.
..
Indicates a range of elements.
<language_id>
The code of a language that exists in the metadata.
See Language codes for the Change Language Script snippet.
<special_element>
Defines a special non-category element. For more information, see Special elements.
<properties>
Defines one or more properties for the element. For more information, see Element properties.
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:
Position
Element name
1
Dinosaurs
2
Conservation
3
Fish_and_reptiles
4
Fossils
5
Birds
6
Insects
7
Whales
8
Mammals
9
Minerals
10
Ecology
11
Botany
12
Origin_of_species
13
Human_biology
14
Evolution
15
Wildlife_in_danger
16
Other
17
Not_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. For more information, see Special elements.
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.
Custom labels have been defined for two languages (ENU for United States English and ESN for International Spanish). These labels are used for only the specified languages; if you select another language, the label stored in the metadata for that language is used.
See also
Table specification syntax