Matching More Than 2 Files

You can merge two or more data sets and specify which records will be merged and which will be excluded using the MATCH command. When you merge data from multiple files, a new data file - a HOLD file - is created that can be used for reporting purposes. The discussion below presumes you are familiar with matching 2 files. For complete information on the MATCH command, refer to your FOCUS documentation, or refer to the training module titled 'Holding & Matching Data' from the Advanced Reporting workbook.  

Match Logic

The MATCH command is typically used to combine data from 2 files into a single hold file. However, the MATCH command can be used to merge up to 6 sets of data. The data sets can be different files, or data from the same file multiple times. The first data set is considered the OLD file, and the second data set is considered the NEW file. If more than 2 data sets are matched, then the HOLD file becomes the OLD file in relation to the next (NEW) data set.

 

 2 data sets             4 data sets    

 

  old    new           old    new         

    \   /                \   /            

     \ /                  \ /             

     hold                H(old)  NEW      

                            \   /         

                             \ /          

                            h(OLD)  NEW   

                               \   /      

                                \ /       

                                HOLD      

Match Syntax

The syntax for matching more than 3 or more files is similar to matching 2 files, except that the RUN command must follow each AFTER MATCH phrase (except for the last one). The END command is only used after the final AFTER MATCH phrase. Note: If the same 'permfile' (e.g., PERMLRG) is used for each of the steps below, then the data held in that file will be over-written each time the data is merged with a new file.

 

DEFINES

Ex filename

Ex filename

Ex filename

Ex filename

OLD

MATCH FILE filename

verb phrase

sort phrase

screening

RUN

NEW

FILE filename

verb phrase

sort phrase

screening

AFTER MATCH HOLD as 'permfile'

merge_phrase

run

NEW

FILE filename

verb phrase

sort phrase

screening

AFTER MATCH HOLD as 'permfile'

merge_phrase

run

NEW

FILE filename

verb phrase

sort phrase

screening

AFTER MATCH HOLD as 'permfile'

merge_phrase

END

HOLD

table file permfile

verb phrase

sort phrase

end