Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with the Metadata Model: Tutorial > Displaying a numeric variable in UNICOM Intelligence Interviewer - Paper
 
Displaying a numeric variable in UNICOM Intelligence Interviewer - Paper
If you try to load the .mdd file that you created in Creating and saving a variable into UNICOM Intelligence Interviewer - Paper, you will find that UNICOM Intelligence Interviewer - Paper does not recognize that there is a numeric variable in the file. In order for UNICOM Intelligence Interviewer - Paper to recognize variables, you must use both the Labels object and the Routing collection.
Here is a revised mrScriptBasic example that allows UNICOM Intelligence Interviewer - Paper to recognize a numeric variable:
Dim MyDocument, MyVariable, MDMRoutingItem

Set MyDocument = CreateObject("MDM.Document")

' Add two languages to Document, and make one of them
' the Document's base language
MyDocument.Languages.Add("ENU")
MyDocument.Languages.Add("DAN")
MyDocument.Languages.Base = "ENU"

MyDocument.Contexts.Add("Paper")

Set MyVariable = MyDocument.CreateVariable("Spend") ' <== Create Spend variable

MyVariable.Labels["Label"].Text["Question"]["ENU"] = _
"How much do you spend on our products per year?"
MyVariable.Labels["Shortname"].Text["Question"]["ENU"] = "Q1"
MyVariable.DataType = mr.Long
MyVariable.MinValue = 0
MyVariable.MaxValue = 1000
MyDocument.Fields.Add(MyVariable)

' Add the "Spend" variable to the MDM's "Paper" routing collection
Set MDMRoutingItem = CreateObject("MDM.RoutingItem")
Set MDMRoutingItem.Item = MyDocument.Fields["Spend"]
MyDocument.Routing.Add(MDMRoutingItem, "Paper")

MyDocument.Save("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\My New Numeric Variable.mdd")
MyDocument.Close()
A similar example in VB.NET is:
Private Sub Creating_and_Saving_Numeric_Variable_For_mrPaper()
Dim MyDocument As MDMLib.Document
Dim MyVariable As MDMLib.IVariable2
Dim MDMRoutingItem As MDMLib.RoutingItem

MyDocument = New MDMLib.Document

' Add two languages to Document, and make one of them
' the Document's base language
MyDocument.Languages.Add("ENU")
MyDocument.Languages.Add("DAN")
MyDocument.Languages.Base = "ENU"

MyDocument.Contexts.Add("Paper")

MyVariable = MyDocument.CreateVariable("Spend")

MyVariable.Labels("Label").Text("Question", "ENU") = _
"How much do you spend on our products per year?"
MyVariable.Labels("Shortname").Text("Question", "ENU") = "Q1"
MyVariable.DataType = MDMLib.DataTypeConstants.mtLong
MyVariable.MinValue = 0
MyVariable.MaxValue = 1000
MyDocument.Fields.Add(MyVariable)

' Add the "Spend" variable to the MDM's "Paper" routing collection
MDMRoutingItem = New MDMLib.RoutingItem
MDMRoutingItem.Item = MyDocument.Fields("Spend")
MyDocument.Routing.Add(MDMRoutingItem, "Paper")

MyDocument.Save(" [INSTALL_FOLDER]\IBM\SPSS\DataCollection\7\DDL\Output\My New Numeric Variable.mdd")
MyDocument.Close()
End Sub
The first change is in the line that creates the Spend variable. Notice that the label is no longer specified as a parameter of the CreateVariable method. Instead, the following two lines have been added:
MyVariable.Labels["Label"].Text["Question"]["ENU"] = _
"How much do you spend on our products per year?"
MyVariable.Labels["Shortname"].Text["Question"]["ENU"] = "Q1"
These lines take advantage of the MDM Labels object.
Defining the label for a variable can sometimes be a frustrating exercise. How can I give a variable a label that is long and descriptive for a CATI interviewer but short and sweet for a CAPI interviewer? What if I want to use different labels during analysis and interviewing? How do I associate question texts in different languages with the same variable? The MDM uses the Labels object to solve these problems. The Labels object is effectively a way to set and retrieve multiple labels for a single variable within a three-dimensional space where the axes are languages, user contexts, and label types.
MDM Labels Object
This graphic is described in the surrounding text.
For example, you might want to set or retrieve a specific variable label where the language is English, the user context is Question, and the label type is Shortname. To do this, the Labels object takes advantage of three MDM Document collections, the LabelTypes collection, the Contexts collection, and the Languages collection.
The example code takes advantage of the optional parameters of the Labels object to create text at three specific coordinates of the Label object's three-dimensional space. In the line MyVariable.Labels["Label"].Text["Question"]["ENU"] = "How much do you spend on our products per year?", Label is specified as the position along the label types axis, Question as the position along the user contexts axis, and ENU (English United States) as the position along the languages axis. The text at these coordinates of the Labels object is set to How much do you spend on our products per year?
UNICOM Intelligence Interviewer - Paper displays texts that have a user context of Question. However, the UNICOM Intelligence Interviewer - Paper Load Questionnaire dialog allows the user to choose which language they want to use. The Language drop-down box in the Load Questionnaire dialog lists all of the Language objects in the Languages collection of the selected MDM Document.
UNICOM Intelligence Interviewer - Paper assumes all variables will have a label type of Label. However, UNICOM Intelligence Interviewer - Paper can take advantage of another label type, that of Shortname. Therefore, the next line is optional:
MyVariable.Labels["Shortname"].Text["Question"]["ENU"] = "Q1"
To see how UNICOM Intelligence Interviewer - Paper takes advantage of the Shortname label type, select the Show Short Names option on the View tab in the UNICOM Intelligence Interviewer - Paper Options dialog.
How can you find out the label type, user context, and language of text in Translation Utility? The language is easy because the languages are represented as individual columns in the Translation Utility grid. When you select Name Column from the View menu in Translation Utility, an extra column shows the variable or category name, and the label type and the user context of the texts as Name (LabelType, Context).
There's one more thing to do to the MDM Document to ensure that UNICOM Intelligence Interviewer - Paper can view the Spend variable, and that is to add it to the paper Routing collection. UNICOM Intelligence Interviewer - Paper gets the list of variables to insert into Word from this collection. A variable can exist in the Document (for example, in the Fields collection) but if it is not in the Paper routing, UNICOM Intelligence Interviewer - Paper ignores it. The following lines are required to add the Spend variable to the paper routing:
' Add the "Spend" variable to the MDM's "Paper" routing collection
Set MDMRoutingItem = CreateObject("MDM.RoutingItem")
Set MDMRoutingItem.Item = MyDocument.Fields["Spend"]
MyDocument.Routing.Add(MDMRoutingItem, "Paper")
The MDM supports several different types of routing. Paper is a routing context. You can use the same variables defined in the MDM Fields collection and add them into a different routing context, such as German Bavaria CAPI, which might define the questions to be asked using CAPI interviewing in the Bavarian part of Germany.
Requirements
See Requirements.
Next topic
LabelTypes, contexts, and languages collections
See also
Working with the Metadata Model: Tutorial
Creating and saving a variable