Desktop User Guides > Professional > Table scripting > Table specification syntax > Special elements
 
Special elements
Element list syntax describes the syntax that you use to specify the elements to include in the axis of a table. This topic documents the special elements that you can include in an axis.
By default, the element name is the same as the element type. For example, by default, a Standard Error element is called stderr. However, if you create multiple elements of the same type, you must specify names to ensure that each element is uniquely identified.
The following list is a summary of the special elements that are available. The other topics in this section contain examples of creating different types of element.
Base
Shows the total number of cases in the variable after any weighting has been applied. Generally, the base includes every case for which the value in the case data is not Null. (This is a change from UNICOM Intelligence Reporter - Survey Tabulation 1.1, where the base excluded empty values as well as Null values.)
If an axis does not include a base element, UNICOM Intelligence Professional creates one automatically at the start of the axis. This means that normally you do not need to use this syntax if you want the base element to appear at the start of the axis. See Base element for further information and examples. See also Restricting a base using an expression.
Syntax
base(['Expression Text'])
Unweighted base
Shows the total number of cases in the variable before any weighting has been applied. In an unweighted table, an unweighted base element shows the same values as the counts in the base element. Only one value is ever shown for an unweighted base element, even when multiple types of cell contents have been requested. The value that is shown is the unweighted base count, regardless what type of cell contents have been requested for the table. By default automatically adds an unweighted base element at the start of each axis in a weighted table. See Base element for further information and examples.
Syntax
unweightedbase(['Expression Text'])
When calculating the values for mean, standard deviation, standard error, sample variance, min, and max elements, UNICOM Intelligence Professional uses the same formulae used for the cell contents. Statistical formulae for more information.
Mean
Shows the mean value of a specified numeric variable, optionally restricted by an expression. See Displaying the mean of a numeric variable. If you do not specify a numeric variable, the mean element shows the mean value of the factors associated with the elements in the axis, and the expression is ignored. See Displaying a mean based on factors.
Syntax
mean([NumericVariable], ['Expression Text'])
Standard deviation
Shows the standard deviation for a specified numeric variable, optionally restricted by an expression. If you do not specify a numeric variable, the element shows the standard deviation for the factors associated with the elements in the axis, and the expression is ignored. For examples, see Mean.
Syntax
stddev([NumericVariable], ['Expression Text'])
Standard error
Shows the standard error for a specified numeric variable, optionally restricted by an expression. If you do not specify a numeric variable, the element shows the standard error for the factors associated with the elements in the axis, and the expression is ignored. For examples, see Mean.
Syntax
stderr([ NumericVariable ], ['Expression Text'])
Sample variance
Shows the sample variance for a specified numeric variable, optionally restricted by an expression. If you do not specify a numeric variable, the element shows the sample variance for the factors associated with the elements in the axis, and the expression is ignored. For examples, see Mean.
Syntax
sampvar([NumericVariable], ['Expression Text'])
Total
Shows the sum of the counts between the most recent base or total element, whichever is the most recent, and the next total or base, or the end of the axis, whichever occurs first. A total element works in this way regardless of its position in the axis. See Displaying totals and subtotals.
Syntax
total()
Subtotal
Shows the sum of the counts between the most recent base, total, or subtotal element, whichever is the most recent, and the next base, total, or subtotal, or the end of the axis, whichever occurs first. A subtotal element works in this way regardless of its position in the axis. See Displaying totals and subtotals.
Syntax
subtotal()
Text
A text-only element that can be used to form a subheading. When the axis is on the side of the table, the element forms a text-only row.
Syntax
text()
Minimum
Shows the minimum value of a numeric variable, optionally restricted by an expression.
Syntax
min( NumericVariable, ['Expression Text'] )
Maximum
Shows the maximum value of a numeric variable, optionally restricted by an expression.
Syntax
max( NumericVariable, ['Expression Text'] )
Net
In a multiple response variable this creates an element that shows the number of respondents who chose one or more categories in a group of categories. A subtotal element for the same categories would show the number of responses given. In a single response variable a net shows the same values as the subtotal. See Creating nets.
Syntax
net({ ElementList })
Combine
This is like a net, except that the elements on which it is based are not shown. See Combining categories.
Syntax
combine({ ElementList })
Expression
This creates a special element that is defined by a custom expression. You can use any expression that is supported by the UNICOM Intelligence Data Model, including any of the functions in the UNICOM Intelligence Function Library. When you are using the hierarchical (HDATA) view, the level of the expression is defined by the level of the variable. You must make sure that all variables included in the custom expression are at this level or are up-leved/down-leved to this level. See Creating an element based on a custom expression. You can use expressions to band numeric variables, autocode text variables, or band date variables.
Syntax
expression(' ExpressionText ')
Numeric
Shows a numeric variable, optionally restricted by an expression. You can use this element type to create summary statistic tables. See Creating summary statistic tables for further information and examples.
Syntax
numeric( NumericVariable, ['Expression Text'] )
Paired Preference
Shows the result of a paired preference test run on a table. See “Paired Preference Test” on page 1201 for further information and examples.
Syntax
ppt()
Derived
Shows a derived element calculated from other elements within the variable using an arithmetic expression. Derived elements use an arithmetic expression based on the values of other elements in the table. This differs from the expression() syntax, which uses a logical expression that tests the case data to determine whether a respondent is included in the count. See Creating a derived element calculated from other elements.
Syntax
derived( 'Expression Text' )
Sum
Shows the sum or total of the values in a specified numeric variable, optionally restricted by an expression. See Displaying the sum of a numeric variable.
Syntax
sum( NumericVariable , ['Expression Text'])
Effective base
Shows the effective base. See Displaying an effective base on a weighted table for more information.
Syntax
effectivebase()
Median
Shows the median for a specified numeric variable, optionally restricted by an expression. See Displaying median and percentile values for more information. You must specify a numeric variable.
Syntax
median( NumericVariable, ['Expression Text'])
Percentile
Shows a percentile for a specified numeric variable, optionally restricted by an expression. You must specify a numeric variable. You must also specify a cut-off value between 1 and 100 to indicate the percentile you want to use. Note that the median element gives the same result as a percentile with a cut-off value of 50. See Displaying median and percentile values for more information.
Syntax
percentile( NumericVariable, CutOffValue, ['Expression Text'])
Mode
Shows the mode for a specified numeric variable, optionally restricted by an expression. See Displaying a mode for more information. If there is more than one mode value, the lowest is displayed. You must specify a numeric variable.
Syntax
mode( NumericVariable, ['Expression Text'] )
Net Difference
Shows the result of a net difference test run on the table. See Net difference test for more information.
Syntax
ntd()
Notes
When calculating the values for mean, standard deviation, standard error, sample variance, min, and max elements, uses the same formulae used for the cell contents. See Statistical formulae for more information.
When you create a special element in UNICOM Intelligence Professional or UNICOM Intelligence Reporter - Survey Tabulation, the Table Object Model creates any helper elements that are required by that element. If you are adding special elements to the metadata using a programming language or a data management script, you might want to create the helper elements explicitly, instead of letting the Table Object Model create them. For more information on the settings for creating special elements and their helper elements, see Special elements and helper elements in metadata.
NumericVariable (AnalysisVariable), Multiplier, and Weight properties must be specified as absolute references. However, variable references in expressions must be specified as relative references. Using the Household.mdd sample as an example, when editing a categorical variable at the person level, if you want to display the mean of man’s weight, you can add the following mean element: mean(person[..].weight, 'gender.ContainsAny({Male})').
Use of analysis variables on parallel levels is not supported. Valid analysis variables must meet the following conditions:
– The variables must be numeric
– The variables must be at the same ascendant level
Take the following variable as an example: variable "person[..].trip[..].purpose"
– Same level analysis variable (valid): person[5].trip[..].transportmodes
– Ascendant level analysis variable (valid): person[..].age, numpersons
– Parallel level (not valid): vehicle[..].mileage
The examples in this section are in a sample mrScriptBasic file called SpecialElements.mrs. Running this sample and examine the exported HTML tables to see each of the example axes in a table. See Running the sample table scripts for more information.
In some examples, the axis specification is presented on multiple lines for clarity. In practice you must specify the axis specification without line breaks.
See also
Displaying the mean of a numeric variable
Displaying a mean based on factors
Displaying totals and subtotals
Creating nets
Combining categories
Creating an element based on a custom expression
Banding numeric variables
Autocoding text variables
Banding date variables
Restricting a base using an expression
Restricting a mean using an expression
Creating a derived element calculated from other elements
Displaying the sum of a numeric variable
Displaying median and percentile values
Displaying a mode
Table specification syntax