Several options are set with parameters of the form '-xi'. These are given after the COPY command and can be given in any order.
infilename.ex1 outfilename.ex2 -x1 -x2 ...
They can also be used at the operating system prompt:
infilename.ex1 outfilename.ex2 -x1 -x2 …
Note that parameters can be entered in either upper or lower case.
Tables from or to databases such as Access must be specified on the command line with a parameter that follows the COPY command:
copy dept.mdb out.dta -tsales
will move the sales table to the file out.dta.
Special Considerations for Database Table Output
Sometimes, when both the input and the output file require a table or subfile specification, the '-T' switch can be ambiguous. In that case, you can modify the switch with a '>' or '<'. The parameter '-T<' means the input table specification and '-T>' means the output table specification.
For example to transfer sheet 3 of an Excel file to an Access table named cities, you could write:
copy in.xls out.mdb -T<sheet3 -T>cities
The wildcard operators '*' and '?' allow you to move more than one input Access data source table with a single command.
For example, suppose the Access data source company.mdb consists of two tables, sales and marketing. Then
copy company.mdb dept.xls -t*
will move each table in company.mdb to a separate Excel worksheet. The output worksheet names will be the root name of the output file that given in the COPY command) with the table names appended, dept_sales.xls and dept_marketing.xls.
Wildcards in the file name can be mixed with wildcards in the Table parameter. For example, to transfer all tables in all of the Access files in the directory indata and write them out in Stata format, you would use
copy indata/*.mdb outdata/*.dta -t*
Specifying Worksheet Ranges
Specifying a Range with a Parameter
Worksheet ranges can be specified with a parameter that follows the COPY command:
where coor gives the coordinates of a specific range and the optional page specification, page!, gives the worksheet page, either as a name or a page number, followed by '!'. If no page is given, then by default the first page is used.
copy sales.wk1 dept1.sas7bdat -ra1:i20
will move the range A1:I20 to the file dept1.sas7bdat, while
copy testdat.wb3 trial1.sav -r4!c6:t200
will transfer the range C6:T200 from page 4 of the worksheet testdat.wb3 to the file trial1.sav.
Specifying Worksheet Pages
Worksheet pages can be specified with either of the parameters:
-Tn or -Tname
where n is the page number and name is the page name. You must use quotes around the entire parameter if name contains blanks.
copy dept.xls out.dta -t3
copy dept.xls out.dta "-tnov sales"
The wildcard operators '*' and '?' allow you to move more than one input worksheet page with a single command.
For example, suppose the worksheet company.xls consists of two pages, sales and marketing. Then
copy company.xls dept.dbf -t*
will move each page to a separate dBASE file. The output file names will be the root name of the output file (that given in the COPY command) with the page names appended, dept_sales.dbf and dept_marketing.dbf.
Wildcards in the file name can be mixed with wildcards in the page parameter. For example, to transfer all of the pages in all of the worksheet files in the directory indata and write them out in Stata format, you would use
copy indata/*.mdb outdata/*.dta -t*
Selecting Members of SAS CPORT or Transport Files
Whenever you select a SAS CPORT or Transport file as input, the first member will be the one used as the input data set, unless you select another one.
If the data you wish to use are in a different member, you must use the parameter '-Tmembername', where membername is the member you wish to select.
COPY infile.xpt outfilename.ex2 -Tmembername
For example, to transfer the data from the member part4 of the SAS Transport file indata.xpt to the Gauss file outdata.dat, type:
copy indata.xpt outdata.dat -tpart4
The wildcard operators '*' and '?' allow you to move more than one member of a SAS Transport file with a single command. The wildcard operators are used for SAS members in the same way that they are used for worksheet pages, as discussed above.
By default, a batch transfer will stop if a file cannot be transferred. To skip errors and continue the transfer, use the '-ws' parameter.