Usage Note 15597: How to convert SAS® data set encoding
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:
%let dsn=libref.datasetname;
%let dsid=%sysfunc(open(&dsn,i));
%let encoding=%sysfunc(attrc(&dsid,encoding)).;
%let rc=%sysfunc(close(&dsid));
%put The encoding for data set &dsn is: &encoding.;
%put The SAS session encoding is: &sysencoding.;
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.
libname inlib cvp 'c:\temp';
libname outlib 'c:\' outencoding='UTF-8';
proc copy noclone in=inlib out=outlib;
run;
The sample code below converts the encoding for a single data set.
libname inlib cvp 'c:\temp';
libname outlib 'c:\' outencoding='UTF-8';
proc copy noclone in=inlib out=outlib;
select data_set_name;
run;
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.
Operating System and Release Information
SAS System | Base SAS | Microsoft Windows XP Professional | 9.1 TS1M3 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 | |
Linux | 9.1 TS1M3 | |
z/OS | 9.1 TS1M3 | |
64-bit Enabled Solaris | 9.1 TS1M3 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 | |
Linux on Itanium | 9.1 TS1M3 | |
HP-UX IPF | 9.1 TS1M3 | |
64-bit Enabled AIX | 9.1 TS1M3 | |
OpenVMS Alpha | 9.1 TS1M3 | |
64-bit Enabled HP-UX | 9.1 TS1M3 | |
Tru64 UNIX | 9.1 TS1M3 | |
*
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.
Type: | Usage Note |
Priority: | |
Topic: | System Administration ==> Installation ==> NLS (National Language Support)
|
Date Modified: | 2021-11-23 15:24:52 |
Date Created: | 2005-06-20 15:51:34 |