all or some of the SAS files in a SAS data library.
- names the SAS data library to copy SAS files to.
To copy an entire SAS data library, simply specify an input data
library and an output data library. For example, the following statements
copy all the SAS files in the SOURCE data library into the DEST data library:
- provides the alter password for any alter-protected SAS
files that you are moving from one data library to another. Because the MOVE
option deletes the SAS file from the original data library, you need alter
access to move the SAS file.
- specifies whether to copy the following data set attributes:
- size of input/output buffers
- whether the data set is
- whether free space is reused.
You specify these attributes with either data set options or SAS system
- BUFSIZE= value for the size of the input/output buffers
- COMPRESS= value for whether the data set is
- REUSE= value for whether free space is reused.
For the BUFSIZE= attribute,
CLONE and the BUFSIZE= Attribute summarizes how the COPY statement works:
CLONE and the BUFSIZE= Attribute
If you use...
||the COPY statement...
||uses the BUFSIZE= value from the input data set for the output data
||uses the current setting of the SAS system option BUFSIZE= for the output
||determines the type of access method, sequential or random, used by
the engine for the input data set and the engine for the output data set.
If both engines use the same type of access, the COPY statement uses
the BUFSIZE= value from the input data set for the output data set. If
the engines do not use the same type of access, the COPY statement uses
the setting of SAS system option BUFSIZE= for the output data set.
For the COMPRESS= and REUSE= attributes,
CLONE and the COMPRESS= and REUSE= Attributes summarizes how the COPY statement works:
CLONE and the COMPRESS= and REUSE= Attributes
If you use...
||the COPY statement...
||uses the values from the input data set for the output data set.
If the engine for the input data set does not support the COMPRESS= or
REUSE= attribute, the COPY statement uses the current setting of the corresponding
SAS system option.
||uses the current setting of the SAS system options COMPRESS= or REUSE=
for the output data set.
||defaults to CLONE.
- specifies whether to copy all integrity constraints when
copying a data set.
- names the SAS data library containing SAS files to copy.
||INLIB= and INDD=
||the libref of the procedure input library
- specifies whether to copy all indexes for a data set when
copying the data set to another SAS data library.
- restricts processing to one or more member types.
||If you omit MEMTYPE= in the PROC DATASETS
statement, the default is MEMTYPE=ALL.
||Manipulating SAS Files
- moves SAS files from the input data library (named with
the IN= option) to the output data library (named with the OUT= option) and
deletes the original files from the input data library.
||The MOVE option can be used to delete
a member of a SAS library only if the IN= engine supports the deletion of
tables. A tape format engine does not support table deletion. If you use a
tape format engine, SAS suppresses the MOVE operation and prints a warning.
||Manipulating SAS Files
- See the description of CLONE .
proc datasets library=source;
copy selected SAS files, use a SELECT or EXCLUDE statement. For more discussion
of using the COPY statement with a SELECT or an EXCLUDE statement, see Specifying Member Types When Copying or Moving SAS Files and see
Manipulating SAS Files for an example.
The MEMTYPE= option in the COPY statement differs from the MEMTYPE=
option in other statements in the procedure in several ways:
You can copy a password-protected SAS file without specifying
the password. However, because the password continues to correspond to the
SAS file, you must know the password in order to access and manipulate the
SAS file after you copy it.
VALIDVARNAME=V6 option is set and the data set has long
variable names, the long variable names are truncated, unique variables names
are generated, and the copy succeeds. If VALIDVARNAME=ANY or V7, the copy
fails with an error if the OUT= engine does not support long variable names.
- A slash does not precede the option.
- You cannot enclose the MEMTYPE= option in
parentheses to limit
its effect to the member immediately preceding it.
- The SELECT and EXCLUDE statements and the IN= option (in the COPY
statement) affect the behavior of the MEMTYPE= option in the COPY statement
according to the following rules:
- MEMTYPE= in a SELECT or EXCLUDE statement takes precedence over
the MEMTYPE= option in the COPY statement. The following statements copy
only VISION.CATALOG and NUTR.DATA from the default data library to the DEST
data library; the MEMTYPE= value in the first SELECT statement overrides the
MEMTYPE= value in the COPY statement.
copy out=dest memtype=data;
- If you do not use the IN= option, or you use it to specify the
library that happens to be the procedure input library, the value of the MEMTYPE=
option in the PROC DATASETS statement limits the types of SAS files that are
available for processing. The procedure uses the order of precedence described
in rule 1 to further subset the types available for copying. The following
statements do not copy any members from the default data library to the DEST
data library; instead, the procedure issues an error message because the MEMTYPE=
value specified in the SELECT statement is not one of the values of the MEMTYPE=
option in the PROC DATASETS statement.
/* This step fails! */
proc datasets memtype=(data program);
select apples / memtype=catalog;
- If you specify an input data library in the IN= option other than
the procedure input library, the MEMTYPE= option in the PROC DATASETS statement
has no affect on the copy operation. Because no subsetting has yet occurred,
the procedure uses the order of precedence described in rule 1 to subset the
types available for copying. The following statements successfully copy BODYFAT.DATA
to the DEST data library because the SOURCE library specified in the IN= option
in the COPY statement is not affected by the MEMTYPE= option in the PROC DATASETS
proc datasets library=work
copy in=source out=dest;
select bodyfat / memtype=data;
When a variable name is truncated, the variable name is shortened to
eight bytes. If this name has already been defined in the dataset, the name
is shortened and a digit is added, starting with the number 2. The process
of truncation and adding a digit continues until the variable name is unique.
For example, a variable named LONGVARNAME becomes LONGVARN, provided that
a variable with that names does not already exist in the data set. In that
case, the variable names becomes LONGVAR2.
Generally, the COPY procedure functions the same as the COPY
statement in the DATASETS procedure. The two differences are
- Truncated variable names can collide with names already
defined in the input data set.
This is possible when the
variable name that is already defined is exactly eight bytes long and ends
in a digit. In that case, the truncated name is defined in the output data
set and the name from the input data set is changed. For example,
retain longvar1-longvar5 0;
proc copy in=work out=sasuser;
run;In this example, LONGVAR10 is truncated to LONVAR1 and placed in
the output data set. Next, the original LONGVAR1 is copied. Its name is no
longer unique and so it is renamed LONGVAR2. The other variables in the input
data set are also renamed according to the renaming algorithm.
can use the COPY statement to copy generation groups. However, you cannot
copy individual generation files.
Typically, you use PROC COPY to transport SAS data sets between hosts.
See The COPY Procedure for more information and an
- The IN= argument is required with PROC COPY. In the COPY statement,
IN= is optional. If omitted, the default value is the libref of the procedure
- PROC DATASETS cannot work with libraries that allow only sequential
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.