Metadata section
The Metadata section is an optional section that can be used to define new variables in the metadata that is used for the transformation. The code in the Metadata section must be valid mrScriptMetadata.
When the DMS file is executed, the metadata defined in the Metadata section is merged with the metadata in the specified data source. You can define only one Metadata section for a data source and the metadata defined in the data source is always used as the master version in the merge operation (see
The master version in a merge operation).
If you have not specified a metadata source in the InputDataSource section (for example, because you are not using the UNICOM Intelligence Data Model OLE DB Provider to read the data or are doing a case data-only transformation) and you define a Metadata section for that data source, the Metadata section will be silently ignored.
Syntax
Metadata [(language [, context [, labeltype] [, datasource]])]
field_name "field description" <type_info>;
...
END Metadata
Parameters
language
Defines the current language for the metadata. Must be a recognized language code. For details of recognized language codes, user contexts and label types, see
Language codes and
Contexts and label types.
context
Defines the current user context for the metadata. User contexts define different usages for the metadata, so that different texts and custom properties can be used depending on how the metadata is being used. For example, the Question user context is typically used to define the default texts to be used when interviewing and the Analysis user context is typically used to define shorter texts for use when analyzing the response data.
labeltype
Defines the current label type. Label types enable different types of labels to be created for different types of information. For example, the default label type of Label is used for question and category texts and variable descriptions, and the Instruction label type is used for interviewer instructions.
datasource
Identifies the input data source for the InputDataSource section.
Notes
You define metadata in mrScriptMetadata by adding field entries to the Metadata section. Each field entry corresponds to a question, loop, block, information item, or derived variable. See
Field definitions in the mrScriptMetadata section for information about defining fields.
A quick way of creating new variables based on other variables is to use one or more expressions. Variables that are defined in the metadata using expressions are known as “dynamically derived variables” because the Data Model calculates the case data for these variables “on the fly”. However, these variables are not understood by products that do not use the UNICOM Intelligence Data Model to read their data, such as IBM SPSS Statistics, Quantum, Excel, and Access. Therefore, dynamically derived variables are automatically converted into “standard” variables. This means that the output data source contains case data for these variables (so that you can use them in IBM SPSS Statistics, Quantum, Excel, etc.) and the expressions are removed from the variables in the output metadata.
However, there is one exception: when you are using the UseInputAsOutput option, dynamically derived variables are not converted to standard variables. This has the advantage that the dynamically derived variables will automatically include any additional case data records that are added to the data source and it is not a disadvantage because you cannot use the UseInputAsOutput option to set up metadata in IBM SPSS Statistics and Quantum data.
Examples
The following metadata section has a default language of English (United States), a default user context of Question, a default label type of Label, and applies to the data source that was defined in the InputDataSource section called Input. It defines two derived Boolean variables for use as filter variables when analyzing the data.
Metadata (ENU, Question, Label, Input)
Entering "Respondents interviewed entering the museum"
boolean expression ("interview = {entering}");
Leaving "Respondents interviewed leaving the museum"
boolean expression ("interview = {leaving}");
End Metadata
All texts and custom properties will be created in the default language, user context, and label type, unless you specify otherwise when you define them.
The following metadata section has a default language of English (United States), a default user context of Question, a default label type of Label, and applies to the data source that was defined in the InputDataSource section called Input. It defines a derived categorical variable named GenderAge within loop called Person for use as filter variables when analyzing the data.
Metadata (ENU, Question, Label, Input)
Person "Person" loop [1 .. 6] fields -
(
GenderAge "Gender/Age Classification" categorical[1]
{
Boys
expression("Gender = {Male} And Age < 18"),
YoungMen "Young men"
expression("Gender = {Male} And Age >= 18 And Age < 35"),
MiddleMen "Middle-aged men"
expression("Gender = {Male} And Age >= 35 And Age < 65"),
OldMen "Older men"
expression("Gender = {Male} And Age >= 65"),
Girls
expression("Gender = {Female} And Age < 18"),
YoungWomen "Young women"
expression("Gender = {Female} And Age >= 18 And Age < 35"),
MiddleWomen "Middle-aged women"
expression("Gender = {Female} And Age >= 35 And Age < 65"),
OldWomen "Older women"
expression("Gender = {Female} And Age >= 65")
};
)
End Metadata
Any variables added in the metadata section need to also appear in the input select statement.
See