This note illustrates how to convert the encoding for a SAS data set.
To determine the encoding of your data set, the following code will write the encoding of the data set and the current SAS session encoding to the log:
The sample code below (for a Microsoft Windows operating environment) converts the encoding for an entire SAS library. UTF-8 is used in the example code as the desired encoding type.
The sample code below converts the encoding for a single data set.
Note: The CVP engine is a read-only engine for SAS data files only. It is not necessary to use the CVP engine to expand the variable length if is already long enough. For more information about the CVP engine, see the section Avoiding Character Data Truncation By Using the CVP Engine in the SAS® 9.4 National Language Support (NLS): Reference Guide, Fourth Edition.
Note: Reading the source file using the CVP engine in the LIBNAME statement will multiply character column lengths by 1.5, or you can use the CVPMULT= option to specify another factor. The macro %COPY_TO_NEW_ENCODING can be used to evaluate all character variables in the source data set and set the proper lengths for the variables that will require it.
Refer to SAS Note 64089, "Frequently asked questions about preparing your site to use UTF-8 SAS® session encoding," for relevant information that you should consider when you are deciding whether to run your SAS programs with UTF-8 SAS session encoding.