When a SAS data set encoded with a different character encoding than the current SAS session is read, automatic transcoding might fail and generate errors similar to the following:
ERROR: Some character data in the data set "XXX.XXX" was lost during transcoding. Truncation occurred during transcoding to the new encoding. To avoid the transcoding error, please refer to "Troubleshooting Truncation and Data loss Issue during Transcoding" in SAS National Language Support (NLS): reference guide.
The error might also occur after you do the following:
In addition, any of the methods described in SAS KB0039558 might produce the error
This issue can occur in any environment where automatic transcoding is performed between different encodings, including:
Here is an example:
Note: The behavior is not limited to MS-950 and might occur with any encoding when invalid byte sequences exist in the source data.
The failure is not necessarily caused by insufficient target variable length.
The Raw Bytes Analysis might reveal that the affected value contains byte sequence that were not valid for the dataset's declared encoding
When SAS performs automatic transcoding, the following occurs:
If invalid or corrupted byte sequences exist in the source data, SAS might be unable to correctly interpret and convert the value, which results in transcoding errors or character data loss.
Because the issue originates from invalid source bytes rather than character length expansion, methods intended to address length growth during transcoding do not resolve the problem.
To resolve this issue, assign the source library using ASCIIANY, and convert the data explicitly.
For more information about the use of SAS functions and statements, see the following resources: