Desktop User Guides > Professional > Data management scripting > Merging case data > Examples of merging case data > Example of a horizontal merge
 
Example of a horizontal merge
This example is provided as a sample data management script file called MergeHorizontal.dms, which is installed with the UNICOM Intelligence Developer Documentation Library. For more information, see Samples.
The two InputDataSource sections both contain JoinKey parameters that specify that the data sources will be joined using the Respondent.Serial system variable. The JoinType parameter in the first InputDataSource section specifies that a full join is required. When the script is run, the two input UNICOM Intelligence Data Files will be merged into a single UNICOM Intelligence Data File called MergeHorizontalOutput.ddf.
InputDatasource(myMasterDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source=mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeHorizontalMaster.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeHorizontalMaster.mdd"
JoinKey = "Respondent.Serial"
JoinType = "Full"
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\MergeHorizontalSecond.ddf; _
Initial Catalog = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Data Collection File\MergeHorizontalSecond.mdd"
JoinKey = "Respondent.Serial"
End InputDatasource

OutputDatasource(myOutputDataSource)
ConnectionString = " _
Provider = mrOleDB.Provider.2; _
Data Source = mrDataFileDsc; _
Location = C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MergeHorizontalOutput.ddf;"
MetaDataOutputName = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\MergeHorizontalOutput.mdd"
End OutputDatasource
The two input files are based on the Short Drinks sample data, which is installed with the UNICOM Intelligence Developer Documentation Library. They contain case data collected using version 5 of short_drinks.mdd. However, the values of Respondent.Serial in both files have been renumbered starting from 1. MergeHorizontalMaster.ddf contains case data for all variables except age and income and is missing respondents 12 and 19. MergeHorizontalSecond.ddf contains case data for the age and income variables but is missing respondents 2, 23 and 26.
1 Run this example script. The output data shows that a case exists for all respondents. However, respondents 12 and 19 contain data for only age and income, and respondents 2, 23 and 26 do not have data for age and income.
2 Change JoinType to “Left”, and then re‑run this script. Respondents 12 and 19 are missing from the output data because they are not in the master data source.
3 Change JoinType to “Inner”, and then re‑run this script. Respondents 2, 12, 19, 23 and 26 are missing from the output data because they are not in both input data sources.
See
Examples of merging case data