After a variable is
defined, the length of a variable can be changed only by a LENGTH
statement. If a variable is read by the SET, MERGE, UPDATE, or MODIFY
statements and the length of the variable is longer than a variable
of the same name, SAS issues a warning message and uses the shorter,
original length of the variable. By using the shorter length, data
will not be truncated.
When you intentionally
truncate data, perhaps to remove unnecessary blanks from character
variables, SAS issues a warning message that might not be useful to
you. To make it so that SAS does not issue the warning message or
set a nonzero return code, you can set the VARLENCHK= system option
to NOWARN. When VARLENCHK=NOWARN, SAS does not issue a warning message
and sets the return code to SYSRC=0.
Alternatively, if you
set VARLENCHK=ERROR and the length of a variable that is being read
is larger than the length that is defined for the variable, SAS issues
an error and sets the return code SYSRC=8.
The VARLENCHECK= system
option does not have any effect on BY variables named in a BY statement
that follows a SET, MERGE, or UPDATE statement. The VARLENCHK= option
applies only to variables with the same name that have different lengths
in two or more data sets. BY variables are excluded by design.
Note: When a BY variable has different
lengths in two or more data sets, a separate warning message is produced,
which is the correct behavior.
WARNING:
Multiple lengths were specified for the BY variable x by input data
sets. This may cause unexpected results.
To
avoid this warning message, you can specify the LENGTH statement prior
to the SET, MERGE, or UPDATE statement to set the BY variable to the
same length.