Problem Note 31850: Using the LENGTH statement might produce a warning and RC=4
A new warning message is produced when the length of a variable changes, with or without a LENGTH statement. The SYSRC is set to 4.
WARNING: Multiple lengths were specified for the variable VOLTYPE by input data set(s). This might cause truncation of data.
When the length of a variable is shortened, data truncation might occur.
SAS® sessions that check the return code now return rc=4 when a LENGTH statement is used to change the length of character variables and some numeric variables.
Explanation
Placing a LENGTH statement immediately after the DATA statement is a standard practice for changing the length of a variable on the input data set(s).
Character variable length is set in the program data vector (PDV) by the length found in the first reference in the DATA step code.
Numeric variables are defined in the PDV as 8 bytes. The length of a numeric variable is determined by the last reference to the variable in the DATA step. The length is set when the variable is written to the output data set.
Solution details for SAS 9.2 TS2M0
Note: A new option has been implemented that turns this behavior on and off.
For more information, see
VARLENCHK= System Option in the SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition.
To get the same behavior as SAS 9.1.3, use the following:
options varlenchk=nowarn;
The new VARLENCHK option does not affect variables in the BY statement. For more information, see
Note 37102: The VARLENCHK= system option excludes BY variables.
Solution details for SAS 9.2 TS1M0
The hot fix turns off the warning and does not set return code, restoring the SAS 9.1.3 behavior.
Click the Hot Fix tab in this note to access the hot fix.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft® Windows® for x64 | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows 2000 Advanced Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Datacenter Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Server | 9.2 TS1M0 | |
Microsoft Windows 2000 Professional | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | 9.2 TS2M0 |
Microsoft Windows XP Professional | 9.2 TS1M0 | 9.2 TS2M0 |
Windows Vista | 9.2 TS1M0 | 9.2 TS2M0 |
64-bit Enabled AIX | 9.2 TS1M0 | 9.2 TS2M0 |
64-bit Enabled HP-UX | 9.2 TS1M0 | 9.2 TS2M0 |
64-bit Enabled Solaris | 9.2 TS1M0 | 9.2 TS2M0 |
HP-UX IPF | 9.2 TS1M0 | 9.2 TS2M0 |
Linux | 9.2 TS1M0 | 9.2 TS2M0 |
Linux for x64 | 9.2 TS1M0 | 9.2 TS2M0 |
OpenVMS on HP Integrity | 9.2 TS1M0 | 9.2 TS2M0 |
Solaris for x64 | 9.2 TS1M0 | 9.2 TS2M0 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The sample code can be used to verify the behavior of the warning. Modify the code to suit your operating system. Examine the results in your SAS log.
/* character variables */
data new;
set sashelp.class;
length Name $5;
run;
data new2;
length Name $5;
set sashelp.class;
run;
/* numeric variables */
data seven;
length x 7;
x=7;
data before76smaller;
length x 6;
set seven;
data after76smaller;
set seven;
length x 6;
data before78larger;
length x 8;
set seven;
data after78larger;
set seven;
length x 8 ;
proc contents data= work._all_;
title inconsistent WARNING and unexpected LENGTH changes;
run;
A LENGTH statement to change the length of an existing data set variable produces a warning message in the SAS log and sets the return code to 4.
Type: | Problem Note |
Priority: | high |
Topic: | SAS Reference ==> Statements ==> Information ==> LENGTH
|
Date Modified: | 2011-08-12 14:51:36 |
Date Created: | 2008-04-18 17:07:11 |