Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with metadata versions > Extracting a single version to a new .mdd file
 
Extracting a single version to a new .mdd file
This example uses the MDM Document.OpenClone method to extract a single version from an existing .mdd file and then writes it to a new .mdd file. This is useful when an .mdd file has become very large because it has many versions but only the one version is needed.
Dim MyCloneDocument

Const MDDFILE = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd"
Const NEWMDDFILE = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\short_drinks_version4.mdd"

Set MyCloneDocument = CreateObject("MDM.Document")

' Open version 4 of the short drinks sample .mdd file
MyCloneDocument.OpenClone(MDDFILE, "4", MDMLib.openConstants.oREAD)

' Save the clone
MyCloneDocument.Save(NEWMDDFILE)
MyCloneDocument.Close()
You can extract a combination of two or more versions, by specifying a version expression as the second parameter of the Document.OpenClone method. For example, this code extracts a combination of all of the versions to a new file:
Dim MyCloneDocument

Const MDDFILE = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd"
Const NEWMDDFILE = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\short_drinks_superversion.mdd"

Set MyCloneDocument = CreateObject("MDM.Document")

' Open all versions of the short drinks sample .mdd file
MyCloneDocument.OpenClone(MDDFILE, "{..}", MDMLib.openConstants.oREAD)

' Save the clone
MyCloneDocument.Save(NEWMDDFILE)
MyCloneDocument.Close()
You can compare the results of the two .mdd files by viewing them using Metadata Model Explorer. When you look at short_drinks_version4.mdd, you can see the variables that were present in version 4 of the Short Drinks sample; when you look at short_drinks_superversion.mdd, you see the combination of all of the versions in the Short Drinks sample. For example, short_drinks_superversion.mdd contains the sclass single response question that was deleted in version 5, and the occup question that replaced it, whereas short_drinks_version4.mdd contains the sclass question but not the occup question.
You are not limited to merging all versions. For example, you could change the version expression to merge two specified versions or a range of versions. For more information, see Version expressions.
See also
Adding versions to the Short Drinks Example .mdd
Working with multiple versions
Activating a version
Working with metadata versions