Adding a special element to the metadata using an axis expression
The
TablesDefineAxesExportToRDB.dms sample (introduced in
Creating axis expressions in the OnBeforeJobStart Event section) also includes a Metadata section that creates an axis expression including a mean element to a variable in a grid.
Metadata (enu, Analysis, Label, Input)
' Add an axis expression including a mean to a variable inside a grid.
' This enables you to show an average in the grid table.
childhhz "Number of children in each age group"
loop
{YEARS_0_5 "0-5 years",
YEARS_6_10 "6-10 years",
YEARS_11_15 "11-15 years"}
fields
(questi1 "Number of children in household" categorical [1]
{CHILDH_0 "None" factor(0),
CHILDH_1 "1" factor(1),
CHILDH_2 "2" factor(2),
CHILDH_3 "3" factor(3),
CHILDH_4 "4" factor(4),
CHILDH_5 "5 or more" factor(5)}
axis("{.., Mean 'Average' mean()}");) grid expand;
End Metadata
This example uses the factors attached to each category to calculate the mean.
You can also create a mean calculated using a numeric variable, by specifying the variable as a parameter. For example, the
TablesDefineAxes.dms sample (introduced in
Creating axis expressions and exporting to IBM SPSS Statistics) includes a Metadata section that creates an axis expression including a mean for the
Human numeric variable in the
Museum sample data set:
' Band a numeric variable
human long
axis ("{NotAtAll 'Not at all interested' expression('human = 1'),
NotParticularly 'Not particularly interested' expression('human = 2'),
NotOpinion 'No opinion' expression('human = 3'),
Slightly 'Slightly interested' expression('human = 4'),
Very 'Very interested' expression('human = 5'),
'Mean' mean(human)}");
See