Desktop User Guides > Professional > Table scripting > Table specification syntax > Element properties > Specifying factors for existing elements

Specifying factors for existing elements
Sample script file: RDBTables.mrs
This example script is based on the Short Drinks sample data set. See Running the sample table scripts for information on running the example scripts.
Displaying a mean based on factors provides an example of basing a mean on the factor values stored for the elements in the metadata. This example shows you how to specify factor values in the axis specification.
hhsize{HH_1 [Factor=1],
HH_2 [Factor=2],
HH_3 [Factor=3],
HH_4 [Factor=4],
HH_5 [Factor=5],
HH_6 [Factor=6],
HH_7 [Factor=7],
Mean 'Average number' mean()}
This example defines factors for the elements in the Household Size (hhsize) variable and creates a special mean element based on the factors we have defined.
Here is a table that has this axis on the side:
Specifying factors for special elements
Element properties
Specifying factors for special elements
You can specify factors for elements you define in your script using custom expressions. This example shows you how to specify factor values for elements used to band a numeric variable.
income{Low 'Low (1)' expression('income > 0 And Income < 50001')
[Factor=1],
Mid 'Middle (2)' expression('income > 50000 And Income < 100001')
[Factor=2],
High 'High (3)' expression('income > 100000') [Factor=3],
Mean 'Mean' mean()
This example bands the numeric income variable into three elements, defines a factor for each element, and creates a special mean element based on the factors. Notice that the factor value has been included in the element labels. This is useful for understanding the tabulated results when you use arbitrary values.
Here is a table that has this axis on the side:
However, when banding numeric variables, it is more usual to base the mean on the raw numeric values. When you do this, you do not need to define factors. For example:
income{Low 'Low' expression('income > 0 And Income < 50001'),
Mid 'Middle' expression('income > 50000 And Income < 100001'),
High 'High' expression('income > 100000'),
Mean 'Mean' mean(income)}
Notice that when you want to base the statistical element on the raw numeric values, you must specify the name of the variable inside the parentheses that follow the keyword that defines the special element (mean in this example).
Here is a table that has this axis on the side: