Merging complete cards
Data for a study might be spread across a number of files. This is useful with large surveys because it means that you can put each card type in a different file and merge in the cards required for the current batch of tables. For example, if you require tables from cards 4 and 5, you need not even read in cards 1, 2, 3 and 6.
Data from up to 16 files may be merged; that is, the main data file and 15 others. It can be merged on serial number and, within that, on card type. With trailer card data, you can also merge trailer cards according to a sequence number entered as part of the data.
For the merge to be successful, all files must be sorted in ascending order with the serial number, card type and sequence number in the same position. Quantum reads the locations from the keywords ser=, crd= and seq= on the struct statement.
To merge data files you must create a file called merges telling Quantum which items to merge on, and which files to merge. The type of merge is represented by a number:
Number | Description |
---|
1 | Merge on serial number. Cards are read in from each data file according to their serial number only — the card type and sequence number, if any, are ignored. You might use this option when you have two files, dat01 containing cards of type 1 and dat02 containing cards of type 2, and you want the files to be merged so that card type 1 is read into the C array, followed by card type 2. |
3 | Merge on serial number and card type (default). With this option, cards with the same serial number read from different data files are merged to form a single record by comparing the serial number and card type. Cards within a record are then sorted sequentially from 1 so that each card is read into the appropriate cells of the C array. For example, if dat01 contains cards 1 and 3, and dat02 contains cards of type 2, the merge will produce records containing cards 1, 2 and 3 in that order. |
5 | Merge on serial number, card type and sequence number. This is similar to merge type 3, except that trailer cards are merged according to their sequence number. For example, if dat01 contains cards 1 and 2, where card 2 is a trailer card with a sequence number of 2, and dat02 contains cards 2 and 3, where card 2 is a trailer cards with a sequence number of 1, the merged record will contain cards 1, 2/1, 2/2, and 3, in that order. |
The type of merge is the first item in the merges file, and is followed by the names of the files to be merged with the main data file named in the Quantum command line. Items may be entered on separate lines or all on the same line separated by semicolons. For example, if you want to merge data in files dat02 and dat03 with data in the main file, dat01, by serial number, card type and sequence number, the merges file would look like this:
5; dat02; dat03
dat01 is not mentioned in the merges file, because it will be named on the Quantum command line instead.
Note This facility is not designed to work with merge files that contain *include or #include statements to read additional data files into the current data file. All merge files must be named in the merges file, which accepts pathnames if the data files are not in the project directory.
See also