Developer Documentation Library > Scripting > mrScriptBasic overview > mrScriptBasic examples > Example 6: Creating an .mdd file from a .sav file
 
Example 6: Creating an .mdd file from a .sav file
This example uses the DSC Registration component to access the SPSS Statistics SAV DSC, which is then used to create an MDM Document. This is subsequently saved as an .mdd file using the MDM Document.Save method.
To improve performance when loading large .sav files into UNICOM Intelligence Reporter(or any other application that uses the UNICOM Intelligence Data Model), always start by creating a .mdd file from the .sav file and then use the .mdd file to load the .sav file. The performance is worse when you do not use a .mdd file, because then the SPSS Statistics SAV DSC has to create an MDM Document “on the fly”, and for a large .sav file this can take a long time.
Code
Dim MDM2, DSC, DSCs

' Create the Data source component Collection
Set DSCs = CreateObject("MRDSCReg.Components")
' Find the SPSS SAV DSC
Set DSC = DSCs["mrSavDsc"]

' Create an MDM Document from the .sav file
Set MDM2 = DSC.Metadata.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Sav\Employee data.sav")

' Save the MDM document out to an .mdd file
MDM2.Save("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\Employee data.mdd")
MDM2.Close()
Using the script
If you want to use the .mdd file to export case data to Quantum, you might want to set up the Respondent.Serial system variable because a serial number variable is required by Quantum DSC when writing the case data. You can do this in two ways:
Include this line so that the .mdd file automatically contains all of the system variables:
MDM.IncludeSystemVariables = True
Include this code to set up the Respondent.Serial variable without the other system variables:
Dim MyClass, MyVariable

Set MyClass = MDM.CreateClass("Respondent", "Variables reserved for respondent identification")
Set MyVariable = MDM.CreateVariable("Serial", "Serial number")
MyVariable.DataType = mr.Long
MyVariable.MinValue = 1
MyClass.Fields.Add(MyVariable)
MDM.Fields.Add(MyClass)
You could also use similar code to create an MDM Document from any other type of proprietary metadata for which you have a read-enabled MDSC. For example, here is the code after it has been amended to create an .mdd file from the Museum sample Quanvert database:
Dim MDM, DSC, DSCs

' Create the Data source component Collection
Set DSCs = CreateObject("MRDSCReg.Components")

' Find the Quanvert DSC
Set DSC = DSCs["mrQvDsc"]

' Create an MDM Document from the Quanvert database
Set MDM = DSC.Metadata.Open("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Quanvert\Museum\qvinfo")

' Save the MDM Document out to an .mdd file MDM.Save(".\Quanvert_Museum.mdd")
See also
mrScriptBasic examples