How to use the ~merge block commands to merge data

Attached are two examples to merge data – one uses a proc and the other one does not.

MERGEDATA_WITHOUT_PROC.SPXis an example that does not use a proc to merge the data.

Sample ~Merge specs with most options used or commented out.

>PurgeSame~In Mrg01.Dat ASCII=50 NumBuf=2 Study=In1 ''Name/Options for Primary File~In Mrg02.Dat ASCII=80 NewBuf   Study=In2 ''Name/Options for Secondary File~Out MrgXX.Dat ASCII Length=100 Trimblanks ''Name/Options for Output File~Merge                            ''Start Merge BlockStatus                              ''Shows current settings (defaults) for ~Merge options''Sort Options''============ Sort_Primary                         ''Required if Primary file not sorted on keySort_Secondary                    ''Required if Secondary file not sorted on key''Write Options''=============Write_Matched                                    ''Write if there is a matchWrite_Unmatched_Primary              ''Write Primary when no match-Write_Unmatched_Secondary       ''Don't Write Secondary when no match''Print Options''=============Print_Unmatched_Primary              ''Warn when Primary is unmatchedPrint_Unmatched_Secondary         ''Warn when Secondary is unmatched''Print_Matched                                    ''Print when files have a match''-Print_Summary                                ''To NOT print summary information''Duplicate Handling Options''==========================Primary_Duplicates_Allowed           ''Allow Duplicates in Primary''Secondary_Duplicates_Allowed     ''Allow Duplicates in SecondaryDisallowed_Duplicates=Warn         ''What to print for a disallowed dup ERROR/OK''Write_Disallowed_Duplicates         ''Still writes out disallowed dups ''Note:  You cannot allow both primary and secondary duplicates in the same run ''Match Keys''==========Primary=In1   Primary_Key=[1.4$]             ''Study Name and Key for the Primary fileSecondary=In2 Secondary_Key=[51.4$]  ''Study Name and Key for the Secondary file''Data to move/Append''===================Append_Location=81          ''Where to start appending data if use Append or Append_All commandMergeCopy [51.10] = [21.10]          ''Copy from 21.10 in Secondary to 51.10 in PrimaryMergeCopy [71.8]  = [11.8]              ''Copy from 11.8 in Secondary to 61.8 in PrimaryAppend [41.10]                       ''Copy from 41.10 in Secondary to end of Primary''Append_All                             ''Append entire Secondary to end of PrimaryStatus                                     ''Shows current settings of all ~Merge options~End

MERGEDATA_WITH_PROC.SPXis an example that does use a proc to merge the data.

Sample ~Merge specs with most options used or commented out.
>PurgeSame~In Mrg01.Dat ASCII=50 NumBuf=2 Study=In1 ''Name/Options for Primary File ~In Mrg02.Dat ASCII=100 NewBuf Study=In2 ''Name/Options for Secondary File ~Out MrgXX.Dat ASCII Length=100 Trimblanks ''Name/Options for Output File ~Def Proc=mrgproc: If In2![21.10^NB] Copy [51.10] = In2![21.10] ''Copy from 21.10 in Secondary to 51.10 in Primary Copy [71.8] = In2![11.8] ''Copy from 11.8 in Secondary to 61.8 in Primary Else Copy [51.10] = In2![61.10] ''Copy from 21.10 in Secondary to 51.10 in Primary Copy [71.8] = In2![71.8] ''Copy from 11.8 in Secondary to 61.8 in Primary Endif} ~Merge ''Start Merge Block Status ''Shows current settings (defaults) for ~Merge options ''Sort Options''============Sort_Primary ''Required if Primary file not sorted on key Sort_Secondary ''Required if Secondary file not sorted on key ''Write Options''============= Write_Matched ''Write if there is a match Write_Unmatched_Primary ''Write Primary when no match -Write_Unmatched_Secondary ''Don't Write Secondary when no match ''Print Options''=============Print_Unmatched_Primary ''Warn when Primary is unmatched Print_Unmatched_Secondary ''Warn when Secondary is unmatched ''Print_Matched ''Print when files have a match ''-Print_Summary ''To NOT print summary information ''Duplicate Handling Options ''========================== Primary_Duplicates_Allowed ''Allow Duplicates in Primary ''Secondary_Duplicates_Allowed ''Allow Duplicates in SecondaryDisallowed_Duplicates=Warn ''What to print for a disallowed dup ERROR/OK ''Write_Disallowed_Duplicates ''Still writes out disallowed dups ''Note: You cannot allow both primary and secondary duplicates in the same run ''Match Keys ''========== Primary=In1 Primary_Key=[1.4$] ''Study Name and Key for the Primary file Secondary=In2 Secondary_Key=[51.4$] ''Study Name and Key for the Secondary file ''Data to move/Append''=================== Append_Location=81 ''Where to start appending data if use Append or Append_All command Proc=Mrgproc Status ''Shows current settings of all ~Merge options ~End

  • mergedata_without_proc.spx
  • mergedata_with_proc.spx
  • mergefile2.dat
  • mergefile1.dat