FCOPY Reference Manual (32212-90008)
Chapter 3 29
FCOPY Applications and Examples
Copying Files
Extracting Parts of Files
Use the SUBSET function to extract portions of a file. You can define a subset as a set of
continuous records or as a set of records with a certain pattern of characters or numbers.
For example, a file may contain information about the employees in your company. Each
record in the file describes one employee, and the employee's last name begins in column 1
of each record. To create a file containing all employees whose last name begins with "S,"
copy the subset of the employee file that contains the character "S" in column 1. To create a
file containing all employees whose last name is "Smith," copy the subset of the employee
file that contains the characters "Smith" beginning in column 1.
Defining Subsets
To copy a subset containing a particular character string from a file, use the following form
of the SUBSET function:
;SUBSET [="
characterstring
"[,[
column
]][,EXCLUDE]]
Substitute the series of characters that you want to match for
characterstring
, and the
beginning column number of the character string for
column
. For example, the command
below copies the subset of all records with the characters "COLLEGE" beginning in
column 40 from the EMPRECS file to the GRADS file:
>FROM=EMPRECS;TO=GRADS;SUBSET="COLLEGE",40
EOF FOUND IN FROMFILE AFTER RECORD 5985
2859 RECORDS PROCESSED * * * 0 ERRORS
To copy a subset excluding specific records, use the EXCLUDE parameter. For example, the
command below copies all records in EMPRECS, except those with the characters
"COLLEGE" beginning in column 40, to the file NONGRADS.
>FROM=EMPRECS;TO=NONGRADS;SUBSET="COLLEGE",40,EXCLUDE
EOF FOUND IN FROMFILE AFTER RECORD 5985
3127 RECORDS PROCESSED * * * 0 ERRORS