Epi Info™ User Guide

Command Reference


Analysis Command: MERGE

Description
This command merges records in one dataset with those in another the Global Record Identifier contained in every Epi Info 7 project to establish the match between records. Records in the second dataset that do not have matching keys can be appended to the end of a dataset. Records in the second dataset that do have matching keys can be used to update records in the main dataset. Records in the second dataset can be used as the parent in defining an Epi Info 7 parent-child relationship after records have been merged into the parent and child forms.

Syntax
MERGE <table specification> {LINKNAME=<text>} [<key(s)>] <type>

  • The <table specification> represents the type and name of a data table to be read as the Merge file.

The <key(s)> represent the Global Record Identifier on which the match or relate will be performed. These are in the form: <ExpressionCurrntTable>::<ExpressionMergeTable>

  • The <MergeType>, may be APPEND, UPDATE or RELATE. If no type is specified, APPEND and UPDATE are performed. For matching records, UPDATE replaces the value of any field in the READ table whose name matches in the MERGE table with the value from the MERGE table unless it has a missing value. For unmatched records, APPEND creates a new record in the READ table with values only for those fields which exist in the MERGE table.
  • Currently, Merge is only supported when the READ and MERGE data source is an Epi Info 7 project.

Comments
APPEND adds unmatched records in the Merge table to the currently active dataset. Only fields found in both datasets are added.

UPDATE replaces fields of records in the active table with those in the Merge table if the key expressions match. Only fields found in both datasets with a non-empty value in the Merge table are replaced.

RELATE moves the unique key of the current table to the foreign key of the related table to make a permanent relationship. The related (Merge) table must be an Access/Epi2000 table. The READ table and the RELATE tables must be Epi Info forms.

Example

This example assumes you have two projects named SampleONE and SampleTWO located in their respective folders.  We want to merge the data from SampleTWO into the SampleONE database.

READ {.\Projects\SampleONE\SampleONE.prj}:Surveillance
MERGE {.\Projects\SampleTWO\SampleTWO.prj}:Surveillance GlobalRecordId :: GlobalRecordId