Desktop User Guides > Professional > Data management scripting > Transferring data using a DMS file > Reading data > Creating an .mdd file from proprietary metadata
Creating an .mdd file from proprietary metadata
When you read from a proprietary data source, it is sometimes useful to create a Metadata Document (.mdd) file; for example, when you want to set up system variables or custom properties and other options in the metadata for use during the export. You can create the .mdd file in the OnBeforeJobStart even section: see Objects in the OnBeforeJobStart Event section.
Creating an .mdd file from proprietary metadata in the OnBeforeJobStart Event section
The following example uses the DSC Registration component to access the SPSS Statistics SAV DSC, which is then used to create an MDM Document object from a .sav file. The MDM Document object is saved as an .mdd file, which is then specified as the input metadata source in the InputDataSource section.
The MDM.IncludeSystemVariables = True line “turns on” system variables in the .mdd file. This is useful when you are transferring data to a relational database using the older ODBC-based RDB DSC, because it requires the Respondent.Serial variable to be present. Typically, .sav files and Quanvert databases do not have a variable called Respondent.Serial. You do not need to assign case data to the variable when you are exporting to an RDB database, because if it is blank, RDB DSC generates a serial number before writing the record. The new OLE DB-based RDB DSC 2 does not require Respondent.Serial to be present.
This example is provided as a sample DMS file (called SavToRDB.dms): see Sample DMS files.
#define EMPLOYEEMDD "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\Employee data.mdd"

Event(OnBeforeJobStart, "Create an .mdd file")

' Use ShellExecute function to call MS-DOS batch file to create the RDB database
ShellExecute("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Scripts\Data Management\Batch\CreateRDBDatabase.bat")

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

' Find the SPSS Statistics SAV DSC
Set DSC = DSCs["mrSavDsc"]

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

MDM.IncludeSystemVariables = True

' Save the MDM document out to an .mdd file that we will use in the file transfer.


End Event

ConnectionString = "Provider=mrOleDB.Provider.2; _
Data Source=mrSavDsc; _
Location=C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Sav\Employee data.sav; _
Initial Catalog=" + EMPLOYEEMDD
End InputDatasource

#define Target "SavToRdb"
#Include ".\Include\RdbOutput.dms"
When you run the DMS file using the validate option, two validation errors occur. For example:
Error opening input data source: myInputDataSource
Failed to close the InputDataSource: myInputDataSource
This is because the validation takes place before the input metadata has been created. You can ignore these errors.
Creating an .mdd file from proprietary metadata in MDM Explorer
1 Open MDM Explorer.
For more information, see MDM Explorer.
2 Click File > Open MDSC.
The Open Metadata Source Component dialog opens.
3 In the Files of Type box, select the type of metadata you want to open.
4 Browse to the folder in which the proprietary metadata is located, and then double-click the file you want to open.
5 Click File > Save As.
6 Enter a name for the .mdd file, and then click Save.
Reading data