Professional > Data management scripting > Merging case data > Examples of merging case data > Example of a vertical merge
 
Example of a vertical merge
This example is provided as a sample data management script file called MergeVertical.dms, which is installed with the UNICOM Intelligence Developer Documentation Library. For more information, see Samples.
There are three InputDataSource sections, which do not contain any JoinKey parameters. (If they did, a horizontal merge would run instead of a vertical merge.) When the script is run, the three input data files are merged into a single file called MergeVerticalOutput.ddf.
InputDatasource(myMasterDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalMaster.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalMaster.mdd"
End InputDatasource

InputDatasource(mySecondInputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalSecond.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalSecond.mdd"
End InputDatasource

InputDatasource(myThirdInputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalThird.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeVerticalThird.mdd"
End InputDatasource

OutputDatasource(myOutputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source = mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MergeVerticalOutput.ddf"
MetaDataOutputName = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MergeVerticalOutput.mdd"
End OutputDatasource

Metadata (ENU, Question, Label, myMasterDataSource)

OriginalRespondentSerial long;
OriginalFile text [30];

End Metadata

Event (OnNextCase, "Create new Respondent.Serial")

OriginalRespondentSerial = Respondent.Serial
Respondent.Serial = dmgrJob.OutputCaseNumber

Select Case (dmgrJob.CurrentInputDataSource)
Case 0 ' Master data source
OriginalFile = "MergeVerticalMaster.ddf"
Case 1 ' Second input data source
OriginalFile = "MergeVerticalSecond.ddf"
Case 2 ' Third input data source
OriginalFile = "MergeVerticalThird.ddf"
End Select
End Event
Each case in the output file will include two new variables, which have been defined in the metadata section. In the OnNextCase event section, the original value of Respondent.Serial is stored in the first new variable and Respondent.Serial is renumbered, starting from one for the first case. In the Select Case statement, the name of the original input file is stored in the second new variable.
The case data contained in the three input files is based on the Short Drinks sample data, which is installed with the UNICOM Intelligence Developer Documentation Library. MergeVerticalMaster.ddf contains the case data collected using version 3 of short_drinks.mdd, MergeVerticalSecond.ddf contains the case data collected using version 4, and MergeVerticalThird.ddf contains the case data collected using version 5. For more information about the differences between these metadata versions, see The Short Drinks sample.
See also
Examples of merging case data