Escolar Documentos
Profissional Documentos
Cultura Documentos
Author(s): Cosmin Bucuroiu, Sergiu Popa, Oana Mihai 1st August 2017
v3
Course Contents
Summary
2 2 2011 Ipsos
Dimensions Overview
Data Collection Concept
4 2011 Ipsos
Data Collection Data Model : File Types
There are two principle types of file that Dimensions can read &
write.
1. Metadata (MDD)
Contains a description of the data file
All question & code text
5 2011 Ipsos
Metadata
Metadata is one of the most important Dimensions files and can include:
Layout information for the way questions are grouped, for example,
loops and grids.
Presentation information, such as the way questions are laid out on the
screen or on the page, and how texts are formatted.
6 2011 Ipsos
Metadata
When used for Interview Scripting it also includes the Script Routing. This is
the logic that controls
Having metadata separate from case data improves the workflow because you
can perform operations on the metadata, such as translating and editing,
independently of case data.
7 2011 Ipsos
Case Data
8 2011 Ipsos
Data Collection Data Model : Overview
Quancept
QDI + DRS Quanvert
Quancept
PKD
+ Quantum
(read only)
QDI + DAT (read only)
DSC
DSC DSC
Triple-S DATA
XML +
DSC
MODEL
ASCII
DSC
DSC DIMENSIONS
Metadata (MDD)
Case Data (DDF)
SPSS
Database Statistics
SAV
9 9
2011 Ipsos
Dimensions Scripting
10 2011 Ipsos
Programming Languages
11 2011 Ipsos
Dimensions Workflow
12 2011 Ipsos
Scripting
Locally processed
Script written in Base Professional
Tested offline on the Scriptwriter's PC.
Define Quotas
Add Translated Texts
Upload files to server using Activation Console
13 2011 Ipsos
Interviewing
Server-based
Testing projects
Live interviews
Survey Management
Progress reports
User management
Sample
14 2011 Ipsos
Data Management
Locally processed
Download data from server
Merge data files
Recoding
Weighting
Add custom variables
Export data
15 2011 Ipsos
Data Management
Locally processed
Tables
Reports
Client deliverables
Survey Reporter - Web
16 2011 Ipsos
Software Tools
Base Professional
Interviewer Server used by SW
DMQuery
Survey Reporter
Web sharing data/tables
Desktop Checking and building tables specs
Workbench Desktop
Artifact Data Table Visualisation
17 2011 Ipsos
Metadata
18 2011 Ipsos
Basic Metadata Item Structure
Metadata items are used to define information texts, questions and sets of
possible responses for an interview.
Additional commands and options can be added to the item before the semi-
colon to enhance functionality and add additional items.
We will look into these later in the course.
mrScriptMetadata names...
20 2011 Ipsos
Metadata Item Types
These are the available item types we can specify in the Metadata section:
21 2011 Ipsos
Special Characters
mrScriptMetadata uses special characters to help layout and separate aspects of
your script. You will become more familiar with these special characters with
practice.
Symbol Name Description
{} Curly brackets Items in brackets define list items
Items in square brackets typically define values and are
[] Square brackets sometimes optional
22 2011 Ipsos
Range Expressions
As we look at each item type in more detail in the following lessons, we will
look at the use of range expressions.
These allow us to get more control over what values can be entered.
They can be applied to all item types except info and boolean.
Range expressions are optional. If one is not specified, the question will be
validated according to the system defaults.
A range expression is defined between square brackets after the item type.
This example will only allow any whole number between 18 and 99 to be
entered.
Age "How old are you?" long [18..99];
23 2011 Ipsos
mrScriptMetadata: Variable Types (1/6)
1. Text
Q4 "What do you think about Coca Cola zero?" text [..100];
2. Numeric long/double
Q2 "What is your age?" long[0..100];
3. Categorical
Q1 "What is your gender?" categorical [1..1]
{
_1 "Male",
_2 "Female"
};
24 2011 Ipsos
mrScriptMetadata: Variable Types (2/6)
4. Loop/Grid
Q8 "How would you rate the following movies?" loop
{
_1 "Silence of the lambs",
_2 "South park - Bigger, longer and uncut",
_3 "Iron Man 3"
} fields -
(
Q8_scale ""
categorical [1..1]
{
_1 "Great",
_2 Mediocre",
_3 "Horrible",
_4 "Haven't seen it" NA
};
) expand;
25 2011 Ipsos
mrScriptMetadata: Variable Types (3/6)
);
);
);
26 2011 Ipsos
mrScriptMetadata: Variable Types (4/6)
7. Info
An information item displays text on the screen.
You use information items to display text that is not related to
the questions such as section titles, instructions to
respondents, or instructions to interviewers.
No data is recorded & range expressions cannot be used.
27 2011 Ipsos
mrScriptMetadata: Variable Types (5/6)
Agree "If you buy another product from Widgets Inc in the future, would
you be willing to do another Satisfaction Survey for Widgets Inc? Tick the
box if you are willing to participate." boolean;
28 2011 Ipsos
mrScriptMetadata: Variable Types (6/6)
29 2011 Ipsos
Categorical Question Syntax
Categorical is the general term for a single-choice or multiple-choice response.
When you define a categorical question, you define the responses from which
choices may be made, and the number of choices that will be allowed.
Response categories are encased in curly brackets, and are defined using the
same syntax as the question and are separated by commas.
A response text is optional. If no text is defined it will use the label, so if your
label is the same as the text there is no need to repeat it.
The semi-colon ";" that ends the question variable appears after the closing
curly bracket "}".
30 2011 Ipsos
Range Expression for Categorical Questions
The range expression for categorical questions has a number of possible
variations which define the restrictions on number of responses a respondent can
give.
31 2011 Ipsos
Range Expression for Categorical Questions
Always specify a minimum of 1 response.
If we do not specify a minimum response we allow the respondent to avoid
answering the question.
Examples
Q1 "Single response" categorical[1..1]
Q2 "Multiple responses" categorical[1..]
Q3 "A minimum of 2 and a maximum of 5 responses" categorical[2..5]
32 2011 Ipsos
Special Keywords on Categories
Special keywords can be added to a category that come into effect during
interviewing.
For now, we will look at exclusive, fix and nofilter keywords.
33 2011 Ipsos
Single-Choice Responses in Multiple Response Lists
Here is an example of using exclusive. If selected, the None category must be the
only answer for the question.
Heard "Where do you recall seeing or hearing advertisements for Widgets Inc in the past
year?" categorical [1..]
{
Television,
Radio,
Newspapers,
Magazines,
Internet,
None "I dont recall seeing or hearing any advert for Widgets Inc" exclusive
};
34 2011 Ipsos
Subheadings
We can group categories together by using sub-headings.
Response categories are grouped by defining a sub-heading name, sub-
heading label/text (optional) and enclosing the responses using curly brackets.
Unlike the question structure the closing curly bracket for a subheading should
NOT be followed by the semi-colon.
Each sub-headed group should be separated by a comma.
35 2011 Ipsos
Shared Category Lists (Define Lists)
Response categories can be shared across questions by defining them as a
shared list. We do this by creating a list of categories using the define keyword.
Shared lists are automatically put to the beginning of the metadata section
when you re-open your .MDD file in Base Professional, unless they have been
defined in blocks where they will appear at the beginning of the block.
Normally, you would not add a text label to the define list unless you are using
it as a sublist and need to define the sublist's heading.
36 2011 Ipsos
Shared Category Lists : Standard Questions
To reference the list in a question add the use keyword followed by the
name of the list where you would normally define your categories.
Like "What aspects did you LIKE about the last product you bought?"
categorical [1..]
{
use attributes -
};
Dislike "What aspects did you DISLIKE about the last product you bought?"
categorical [1..]
{
use attributes -
};
37 2011 Ipsos
Shared Category Lists : Standard Questions
When referencing more than one category list at a question, use lines must
still be separated by a comma as if it were a normal response option.
In this example, two category lists are combined into one single list during
the interview.
Heard "Where do you recall seeing or hearing advertisements for Widgets Inc in
the past year?"
categorical [1..]
{
use newspapers,
use magazines
};
38 2011 Ipsos
Shared Category Lists: Grids and Loops
Shared category lists can also be used to define loop categories as well as
lists for questions inside loops.
LikeDislike_Loop loop {
use Brand_list
} fields (
Like "What aspects did you LIKE about {@}?" categorical [1..]
{
use attributes -
};
Dislike "What aspects did you DISLIKE about {@}?" categorical [1..]
{
use attributes -
};
) expand;
39 2011 Ipsos
Special Responses Categories
Dont Know
dk
exclusive, fix and nofilter keywords are applied automatically.
Refused
ref
exclusive, fix and nofilter keywords are applied automatically.
No Answer
na
exclusive, fix and nofilter keywords are applied automatically.
Other (specify)
Adds a text box next to the category code.
other If text is entered, the category check box must be clicked.
Unlike dk, ref and na, the exclusive, fix and nofilter keywords must be
added to suit the demands of the survey.
40 2011 Ipsos
Special Responses in a Categorical Question
Here is an example of the special categories in use:
Items "What items did you purchase from Widgets, Inc. the LAST time you placed an
order?" categorical [1..] {
Jumbo,
Large,
Medium,
Small,
OtherItem "Other Item(s) - please separate items with commas" other,
- "Dont recall" dk,
- "Refused" ref,
- "No Answer" na
};
41 2011 Ipsos
Other (Specify)
Adding the other keyword opens up a text box for respondents to add their own responses.
You can further modify the inherent properties of the other category:
You can modify the data type and further modifications specific to that data type. In the
above example we have specified that the text is stored in a variable called OtherItems and
restricted it to 100 characters.
Example:
Q6 Select brands purchased in the past 6 months categorical[1..]
{
Use Brandlist,
_997 Other (please specify) other(oth My Text text[1..100])
};
42 2011 Ipsos
Adding Special Responses to Text or Long Questions
It is also possible to add special category codes onto text or numeric questions.
Categories can be added to the variable in the codes section.
Inside the codes section, all categories are specified between curly brackets {
as usual.
NumTimes "On average, how many times per year do you order something from
Widgets Inc.?" long [0..20]
codes (
{
- "I cannot remember" dk
}
);
43 2011 Ipsos
Sorting & Ordering Categorical Responses
These are keywords that manage the orientation of categorical response lists.
WhereUse "Where have you been using your Widgets Inc product since you purchased it?"
categorical [1..]
{
Home "Inside your Home",
Garden "In your Garden",
Work "At Work",
NotUsed "I've not been using it since I purchase it" exclusive
} ran;
44 2011 Ipsos
mrScriptBasic: Statements (1/3)
1. Assignment Statements
variable = expression
45 2011 Ipsos
mrScriptBasic: Statements (2/3)
2. Conditional Statements
1. If Then Else
If expression Then
[statements]
[ElseIf expression-n Then
[elseifstatements]]
...
[Else
[elsestatements]]
End If
2. Select Case
Select Case testexpression
[Case expression-n
[statements-n]]
...
[Case Else
[elsestatements]]
End Select
46 2011 Ipsos
mrScriptBasic: Statements (3/3)
3. Iteration Statements
1. For Next
For counter = start To end [Step step] [{Ran|Rot|Rev} [it]]
[statements]
[Exit For]
[statements]
Next
2. For each
For Each element In group
[statements]
[Exit For]
[statements]
Next
47 2011 Ipsos
mrScriptBasic: Variables
MaxRating = 100
[statements]
MinRating = MaxRating/2
MaxRating = 50
48 2011 Ipsos
mrScriptBasic: Variables - Arrays
Declaration
'An array of 10 elements
dim A[10]
'An array of dynamic dimension
dim A[]
You assign data to each of the elements of the array using an index into the
array. Indexes are 0 based in mrScriptBasic. Maximum array index for A[10]
is therefore 9.
A[0] = 256
A[1] = 324
A[2] = 100
...
A[9] = 55
Dim MyArray[2]
MyArray[0] = "Hello"
MyArray[1] = " World"
49 2011 Ipsos
mrScriptBasic: Variables - Arrays
50 2011 Ipsos
mrScriptBasic: Variables - Arrays
Limitations:
You can only have as many as 60 dimensions in an array.
The maximum number of items in any one dimension of an array
is 65536.
51 2011 Ipsos
mrScriptBasic: Conversion Functions
52 2011 Ipsos
DM Query
53 2011 Ipsos
Running Queries in DM Query (1/4)
54 2011 Ipsos
Running Queries in DM Query (2/4)
For the Metadata Type you can leave as the default "Data Collection
Metadata Document".
This is the MDD file.
Browse to the location of your MDD & DDF files and select the MDD file.
From the Case Data Type drop-down list, select Data Collection Data File
(read-write).
Enter the Case Data Location using Browse if the DDF file has not been
found automatically.
Leave the Case Data Project text box blank.
55 2011 Ipsos
Running Queries in DM Query (3/4)
Click the Advanced tab, and from the Categorical Variables drop-down
list, select Return data as category names.
Click OK.
This returns you to the DM Query window.
56 2011 Ipsos
Running Queries in DM Query (4/4)
To view the data we need to enter an
SQL Query.
Enter this query to view all variables
in the VDATA table
57 2011 Ipsos
SQL Queries
View data for all variables in VDATA.
SELECT * FROM vdata Same can be used for hierarchical data by referencing HDATA instead.
SELECT serial, age, gender FROM vdata Show data for serial, age and gender variables.
SELECT DISTINCT gender, before FROM vdata Uses the DISTINCT command to deduplicate the results shown
58 2011 Ipsos
Creating a Basic Table
Lesson 1
Creating a Basic Table
Lesson Objectives
60 60 2011 Ipsos
Create Your Initial Script
61 61 2011 Ipsos
Decomposing the Script
Dim objTableDoc
62 62 2011 Ipsos
Decomposing the Script
63 2011 Ipsos
Decomposing the Script
objTableDoc.DataSet.Load(Day 1.mdd",,_
Day 1.ddf","mrDataFileDsc")
64 2011 Ipsos
Decomposing the Script
Dim objTable
Set objTable = objTableDoc.Tables.AddNew(Table1, Q1* Q2, My
First Table)
65 2011 Ipsos
Decomposing the Script
66 2011 Ipsos
Decomposing the Script
objTableDoc.Populate()
67 2011 Ipsos
Decomposing the Script
objTableDoc.Save(Day 2.mtd)
68 2011 Ipsos
Decomposing the Script
With TableDoc.Exports[mrHtmlExport]
.Properties[Interactive] = True
.Properties[LaunchApplication] = True
.Properties[DisplayOption] = Table Only
.Export(Day 2.htm)
End With
69 2011 Ipsos
Basic Code Structure Used in Exporting Tables
With TableDoc.Exports[mrHtmlExport]
.Properties[DisplayOption] = Table Only
.Properties[LaunchApplication] =True
.Properties[Interactive] = True
.Export(Day 2.htm)
End With
70 2011 Ipsos
Basic Code Structure Used in Exporting Tables
.Properties[OverwriteOutput] = True
71 2011 Ipsos
Change Tables/Categories Labels
Variable Label
objTableDoc.DataSet.MdmDocument.Fields[Q1"].Label="Gender"
Category Label
objTableDoc.DataSet.MdmDocument.Fields[Q1"].Categories[{_1}].Label =
MALE"
Best Practice
Dim MDM
MDM=objTableDoc.DataSet.MdmDocument.Fields
MDM["ISQ20"].Label="Gender
72 2011 Ipsos
Nesting and Concatenating Variables
Generally the evaluation takes place from left to right and the
> symbol takes precedence over the +
73 2011 Ipsos
Concatenating Variables
74 2011 Ipsos
Nesting Variables
75 2011 Ipsos
Ordered Nesting and Concatenation
Examples:
Q1> Q3+ Q5
Q5+ Q6> Q1
76 2011 Ipsos
Axis expression
Lesson 2
Creating Nets
Overview
78 2011 Ipsos
Variable Presentation Axis Expression using {}
In this case all the categories are included, {Yes, No, Ref}
The category names are from the mdd, open and use this as
reference
79 2011 Ipsos
Expanding categoricals
Example:
same thing as
80 2011 Ipsos
Excluding categories from tables
81 2011 Ipsos
Hidding Categories [IsHidden=true]
You can leave out categories you dont want to show in a table from the
axis expression
Its generally better to hide categories so its clear that the category exists.
82 2011 Ipsos
Base and Total
Set objTable =
objTableDoc.Tables.AddNew("Table8",Q1{base()[isHidden=true],_1,_2,_3,_4,_5,_6,_7}
* Q2{base() [isHidden=true],_1,_2}","Cross Age by Gender")
83 2011 Ipsos
Variable Presentation New Categories combine() and net()
The double dots .. are used to specify the rest of the question is to be
shown as per the mdd
84 2011 Ipsos
Creating nets
Net
Set objTable=objTableDoc.Tables.AddNew("Table1",Q1{base(),_
net1 'Category 1' net({_1,_2,_3}),net2 'Category 2' net({_4,_7,_8}),_
net3 'Category 3' net({_5,_6})}*Q2",Q1 with nets crossed by Gender")
Combine
Set objTable=objTableDoc.Tables.AddNew("Table1",Q1{base(),.., _
net1 'Category 1' combine({_1,_2,_3}),net2 'Category 2' combine({_4,_7,_8}),_
net3 'Category 3' combine({_5,_6})}*Q1",Q1 with nets crossed by Gender")
85 2011 Ipsos
Sorting Tables
We can specify how we sort the rows and columns in a table
objTable.SortRow = "first|last|variable{category}"
objTable.SortColumn = "first|last|variable{category}"
The special elements such as base, na, dk, other, refused are
not sorted and should be fixed
86 2011 Ipsos
Sorting tables
objTableDoc.Tables["Table1"].SortColumn=Q1{_1}"
objTableDoc.Tables["Table1"].SortColumn=First"
87 2011 Ipsos
Tabulating an open variable
88 2011 Ipsos
Statistical elements and more
Lesson 3
Statistics
Overview
Adding Factors
Mean
Standard Error
Standard Deviation
Mean/Median on numeric variables
Derived/expression
90 2011 Ipsos
Adding Factors (1/2)
91 2011 Ipsos
Adding Factors (2/2)
On MDM Document
objTableDoc.DataSet.MdmDocument.fields[Q2"].categories["_5"].Factor=5
objTableDoc.DataSet.MdmDocument.fields[Q2"].categories["_4"].Factor=4
objTableDoc.DataSet.MdmDocument.fields["Q2"].categories["_3"].Factor=3
objTableDoc.DataSet.MdmDocument.fields["Q2"].categories["_2"].Factor=2
objTableDoc.DataSet.MdmDocument.fields["Q2"].categories["_1"].Factor=1
92 2011 Ipsos
Statistical elements(Categorical Variables)
Mean
Set objTable = objTableDoc.Tables.AddNew("Table2",Q1{..,Mean 'Medie'
mean()}*Q2","Cross Region by Gender")
Standard Error
Set objTable = objTableDoc.Tables.AddNew("Table2",Q1{..,StdErr 'Standard
Error' stderr()}*Q2","Cross Region by Gender")
Standard Deviation
Set objTable = objTableDoc.Tables.AddNew(Table2",Q1{..,StdDev 'Standard
Deviation' stddev()}*Q2","Cross Region by Gender")
93 2011 Ipsos
Statistical elements (Numeric Variables)
Median
94 2011 Ipsos
Derived, expression, text elements
You can add empty rows with just a text on the axis
Set objTable = objTableDoc.Tables.AddNew("Table2",Q1{..,t1 This is just text'
text()}*Q2","Cross Region by Gender")
95 2011 Ipsos
Filters
Lesson 4
Applying Filters to Tables
Overview
97 2011 Ipsos
Common Operators Used When Filtering
Symbol Description
= Equal to
< Less than
<= Less than or Equal to
<> Not Equal to
> Greater than
>= Greater or Equal to
98 2011 Ipsos
Functions & Operators Used When Filtering
Predefined Functions
- AnswerCount
- ContainsAll tests if all specified answers are included
- ContainsAny tests if at least the specified response is cheked
- ContainsSome
99 2011 Ipsos
Common Operators Used When Filtering
Categorical
SA
{cat_name} if answered
(null) if not asked
MA
{cat1_name, cat1_name,.} if answered
(null) if not asked
All variables have a default value if they are asked, but not answered blank for
strings, {} for SA and MA; for numeric variables a default value must be set.
GRID
vdata
One variable for each iteration: GridName[{iteration_name_n}].QuestionName
{cat_name} if answered
(null) if not asked
SA
= {cat}
<> {cat}
AnswerCount()
MA
= {cat}
<>{cat}
ContainsAny({cat1,cat2,})
not ContainsAny({cat1,cat2,})
AnswerCount()
OE & Numeric & Loop
Is null
Is not null
objTableDoc.Tables["Table5"].Filters.AddNew("MalesOnly",
"ISQ20.ContainsAny({_1})","Only Males")
Set objTable
Obj TableDoc.Tables[0].Filters.Add(MalesOnly)
You can also add a filter directly on the Table object rather than
referencing the table from the Table Doc Object by name
NB: As you will most likely be using the same object name to set different
tables throughout your script, use this right after creating your tables,
before objTable changes definition.
objTableDoc.Default.Filters.AddNew("MalesOnly","ISQ20.C
ontainsAny({_1})","Only Males")
objTableDoc.Default.Filters.Remove(MalesOnly)
objTableDoc.Global.Filters.AddNew("MalesOnly","ISQ20.C
ontainsAny({_1})","Only Males")
Overview
Summary Table
One Table for each statement
Set objTable =
objTableDoc.Tables.AddNewGrid("GridTable","ISQ45",,"ISQ45
Summary Table")
Set objTable =
objTableDoc.Tables.AddNew("GridTable1",Q1*Q1.Q1_scale", Q1
Summary Table")
Best Practice:
A for instructioncan be used to iterate to all statements of the grid
and build one table for each one:
dim i
for i=1 to 3
Set objTable = objTableDoc.Tables.AddNew("ISQ1_"+ctext(i),
"ISQ1[{_"+ctext(i)+"}].Q1_scale*Q1","ISQ45_"+ctext(i)")
next
Overview
To remove counts
objTableDoc.Tables["Table2"].CellItems.Remove(0)
Count(0)
Column Percentage(1)
Row Percentage(2)
NB: The above codes are valid only when adding CellItems
objTableDoc.Default.CellItems.Remove(1)
objTableDoc.Default.CellItems.AddNew(1,2)
objTableDoc.Default.CellItems.Remove(1)
objTableDoc.Default.Rules.AddNew(,1)
Objectives
Applying a statistical test to a table
Specifying Column Labels
Specifying Columns to Test
Changing properties of the Test including Sig Level
objTableDoc.Default.Statistics[0].Properties["MinBase"] = 30
objTableDoc.Default.Statistics[0].Properties["SmallBase"] = 50
Important:
As you noticed, the Column IDs and the Column Tests are defied to
the table level because headers can be different from table to table
If the Columns IDs and Column Tests are consistent to the document
level, functions or for can be used to define them only once
objTableDoc.Default.Statistics.GridDetectionMethod = 1
objTableDoc.Dataset.Variables.AddNewVariable("!
buyers "Buyers Non Buyers"
categorical [1..1] {
_1 "Buyers" expression("ISQ40a.ContainsAny({_1,_2,_3})"),
_2 "Non Buyers" expression("Not ISQ40a.ContainsAny({_1,_2,_3})")
}
!")
Overview
Recoding
Average number of Mentions
Side by Side tables
Top Box / Top 2 Box
Database Merging
Weighting
Definition
DMOM is method by which data management solutions are
created
Stands for Data Management Object model.
Is a series of library scripting functions used to create data
management solution.
Process/reads in a survey and dataset (known as input),
modifies or manipulates the information stored in there
exports this revised survey and dataset (known as output)
126
Definition
The InputDataSource section defines the input data source for the data transformation.
Overview
References input data and survey files
Typing code manually or use macros and wizards
Input metadata and data files located in same directory as the data management script.
Format:
NOTE: SelectQuery filters the view of the input data files. Without this all records selected.
<Description of Event>optional, but recommended to describe nature dataset
<InputName> referenced in other Data management events
All the keywords in a Data Management are case insensitive
127
Definition
The OutputDataSource section defines the output data source for the data transformation.
128
When creating a Data management script solution there may be times where
we need to create additional derived variables, that we know will be needed in
the newly exported output data files.
The Metadata section of a Data Management script allows us to accomplish
that.
Definition
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
This is the same language used to create variables under IOM (Interviewing
Object model).
Example
Metadata(ENG,Question,Input)
<metadata variables>
End Metadata
129
You may write your events in any order in your Data Management Script but
they will always be processed in the order pre-determined by the DMS
architecture.
8
New OnJobStart
Metadata Variables
9 Repeat for
OnNextCase each
Respondent
5 2
10
GlobalSQL
Variables
OnBadCase
6
OnAfterMetadata 11
Transformation Create Output OnJobEnd
Structure
7
Update Query
12
OutputDataSource
131 2011 Ipsos
Data Management Script Procedure
OnBeforeJobStart Event Section
This is typically used to set up card and column allocations in the input data source's metadata
in a job that exports case data to Quantum.
Metadata Section
The metadata in the InputDataSource section is merged with any metadata defined in the
Metadata section.
The merged metadata is then available to the input data source so any new variables (from the
Metadata section) that have been included in the Select Query statement will be returned by
the query.
There are many occasions when we need to access to the file system
from within a Data Management Script. Such as:
The FSO model gives you the ability to work with files and
folders to:
Create
Modify / append
Move
Delete
Determine if and where they exist
Access information such as:
Path names, file extensions, dates created, modified or last accessed
Get drive information:
Number of drives, available space
NOTE: The FSO can be referenced in all Data Collection scripts, i.e. interview
routing, data management, tabulation or mrScriptBasic files.
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile("OriginalFilename","CopyFilename",overwrite)
FSO.CopyFolder("OriginalFoldername","CopyFoldername",overwrite)
Move / Rename
FSO.MoveFile("OriginalFilename","NewFilename")
FSO.MoveFolder("OriginalFoldername","NewFoldername")
Delete
FSO.DeleteFile("Filename",force)
FSO.DeleteFolder("Foldername",force)
FSO.CreateFolder("FolderName")
Definition
The OnNextCase event is used to define procedural code that is to
be applied to each selected case or record.
Overview
Examples
Cleaning any records for invalid or irrelevant responses
Using logic to build or persist new derived variables from Metadata
event
Dropping entire records from data set i.e. failed screener
Accessing any global objects i.e. writing to an Excel file
Example
If ISQ40A.containsAny({_1,_2,_3}) then Buyers={_1}
If not ISQ40A.containsAny({_1,_2,_3}) then Buyers={_2}
DMS
Metadata(ENG_GB,Question,Label)
ISQ40Av Av No of Mentions long;
End Metadata
MRS
Set objTable=objTableDoc.Tables.AddNew("TableQ40a",
"ISQ40a{..,Av Average No of Mentions mean(SQ40Av)}*
ISQ20",Average Number of Mentions")
DMS
Metadata
Q41Q41a "ISQ41.ISQ41a Side by side" loop
{
ISQ41 "Q41",
ISQ41a "Q41a"
} fields
(
GV1 "" categorical [1..1]{
_1 "I buy it myself and I choose the brand",
_2 "I buy it myself, even if I dont always choose the brand",
_3 "I choose the brand, but someone else buys it for me",
_4 "Someone else buys it and I dont choose the brand",
_5 "I use whatever is available at home"}
)expand grid;
OnNextCase Event
Q41Q41a[0].gv1=ISQ41
Q41Q41a[1].gv1=ISQ41a
DMS
Metadata
ISQ45TB "Brand Equity" categorical[1..]
{
_1 "Allergy treatment products in the spring /summer",
_2 "Allergy treatment products in the autumn/winter",
_3 "Allergy treatment products on average through out the year
}
OnNextCase Event
dim i, check
check=0
for each i in ISQ45.categories
if ISQ45[ccategorical(i)].scale.containsAny({_1,_2}) then ISQ45TB = ISQ45TB + ccategorical(i)
if ISQ45[ccategorical(i)].scale is not null then check=1
next
if answercount(ISQ45TB)=0 and check=1 then
ISQ45TB = {}
end if
MRS
Set objTable=objTableDoc.Tables.AddNew("ISQ45T2B","ISQ45TB*ISQ20","Q45 Top 2 Box")
Vertical merge:
two or more input data sources and one output data source
See \\rofs01\Dimensions\01. Training\02. Ipsos Training
Materials\05.DP\Merge\MergeVertical.dms
Horizontal Merge:
two or more input data sources and one output data source+
JoinKey defined in each input data source
See \\rofs01\Dimensions\01. Training\02. Ipsos Training
Materials\05.DP\Merge\MergeHorizontal.dms
JoinKey
The variable used for matching across data files.
If you do not specify a JoinKey the DMS will attempt a vertical merge instead
(see next lesson).
JoinType
How the data files should be merged.
Required on the Master Input Data Source Only.
JoinKeySorted = True
When running a horizontal merge all input data sources are sorted
automatically.
If your data files are already sorted, you can speed up processing by switching-
off the sorting by using this command.
JoinType Description
All cases on all input data sources are written to the output data.
Full Cases with identical JoinKey values are combined before writing.
This is the default behavior if JoinType is not specified.
Only cases with identical JoinKey values on all input data sources are written to the
Inner output data.
The cases will be combined before writing.
Only cases with JoinKey values that exist in the master data source are written to the
Left output data. Cases with identical JoinKey values are combined before writing.
NOTE: The first data source is known as the master data source.
InputDatasource(myMasterDataSource)
ConnectionString = "Provider=mrOleDB.Provider.2;_ Add these two
Data Source=mrDataFileDsc;_ Join Commands
Location=First.ddf;_
Initial Catalog=First.mdd"
for matching
SelectQuery = "SELECT * FROM VDATA" purposes
JoinKey = "Respondent.Serial"
JoinType = "Left"
End InputDatasource
InputDatasource(mySecondInputDataSource)
ConnectionString = "Provider=mrOleDB.Provider.2;_
Data Source=mrDataFileDsc;_ Define the
Location=Second.ddf;_ variable to be
Initial Catalog=Second.mdd"
SelectQuery = "SELECT * FROM VDATA"
used for
JoinKey = "Serial" matching
End InputDatasource
OutputDatasource(myOutputDataSource)
ConnectionString = "Provider=mrOleDB.Provider.2;_
Data Source=mrDataFileDsc;_
Location=Merged.ddf;_
MR Init MDM DataSource Use=2;_
MR Init Overwrite=1"
MetaDataOutputName = "Merged.mdd"
End OutputDatasource
InputDatasource(InputWave1)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = " + file1 + ".ddf; _
Initial Catalog = " + file1 + ".mdd"
End InputDatasource
Now create the Output data source, this time referencing the fileall text
substitution.
OutputDatasource(OutputAllWaves)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source = mrDataFileDsc; _
MR Init Overwrite=1;_
Location = " + fileall + ".ddf"
MetaDataOutputName = fileall + ".mdd"
End OutputDatasource
Steps to follow:
1. In the metadata section define the weighting variable
2. Initiate Weight Engine
3. Define Weighting Report File
4. Define the weighting axis
5. Define the weighting matrix
6. Execute the Weighting
7. Write the weighting Report in the file defined above
Factor Weighting You use factor weighting when you already know
the weighting factor for the respondents in each population group on
which you are basing your weighting
Target Weighting You use target weighting when you know the
total number or proportion of respondents that you want to appear
in each cell of the table.
RIM Weighting this is the most used; you use it when
You want to weight according to various characteristics, but you do not
know the relationship of the various combinations of those
characteristics.
You want to weight using target weighting but there are no respondents
who fulfill the requirements of one or more of the cells of the target
weighting table.
For more information on weighting, please visit:
http://pic.dhe.ibm.com/infocenter/spssdc/v6r0m1/topic/com.spss.d
dl/weight_overview.htm
JobEnd Event
dim WgtEng, Wgt, fso, ReptFile
2.Initiate Weight Engine
set WgtEng = dmgrJob.WeightEngine
MRS
objTableDoc.Default.Weight="pond
objTableDoc.Default.Properties["AutoUnweightedBases"] = False
Overview
MRS
Create the table for each OE Question, including nets and other data
processing
Metadata(ENG_GB,Question,Label)
codeframe define
{
_1 Cute/Clever
_2 Amusing/humorous/entertaining,
_3 Exciting/holds attention/interesting,
_3001 Surprising,
_3002 Intriguing,
_4 Appealing/attractive/pleasant,
_4021 Clean / Cleanliness,
_4023 Easy / Easy to watch,
_4024 Happy/cheery
}
End Metadata
StartJoc
Net3 Cute/clever
1 Cute/clever
Net3 Amusing/humorous/entertaining
2 Amusing/humorous/entertaining
3 Exciting/holds attention/interesting
3001 Surprising
3002 Intriguing
Net3 Appealing/attractive/pleasant
4 Appealing/attractive/pleasant
4024 Happy/cheery
If Respondent.ID =20212177 then QF4aOE=Unique{_148,_85,_1,_44,_64,_98,_161}
End Event