"Loose" Algorithm for lab 7 use a SORT statement to sort the "master" file use a SORT statement to sort the "add" file use a MERGE statement to merge the "master" and "add" files initialize array read merged file repeat until end of merged file move input-rec to table to store each record in a 1-dim array read merged file end-repeat close merged file read delete file repeat until end of delete file use a SEARCH statement to find the record to delete in the table when found, remove record from table read delete file end-repeat close delete file set index to 1 repeat until end of table if record in table, write it to master file end-repeat Some notes: The object here is to update a master file by applying some adds and deletes. You have a master file, add file and delete file. The add file contains patients to add to the master file and the delete file contains patients to remove from the master file. You do not have to worry about trying to add a patient that's already there. You can assume that the data is OK. The MERGE will combine 2 sorted files into one. So that will take care of the adds smoothly. To do the "delete" function you will load the merged file into a 1 one dimensional table. Each element of the table is a copy of the input record. Unlike lab 6, you will load the records into the table sequentially (1st record has subscript 1, next one has a subscript of 2, etc.). Maybe a PERFORM VARYING until end of file? Once that's done, you will read the delete file. SEARCH the table looking for a match. If you find a match then "remove it" from the table. Don't actually remove it from the table, just set its keys to zero or whatever initial value those fields have. Once you've cycled through the delete file you will then write the remaining records to the file. Iterate through the table and if a record is there (keys not the initial value) then write that record to the master file (which shouldbe output now). Don't forget ORGANIZATION IS LINE SEQUENTIAL on all files. It will bite you hard, here, if forgotten.