The value for ENCODING=
indicates that the SAS data set has a different encoding from the
current session encoding. When you read data from a data set, SAS
transcodes the data from the specified encoding to the session encoding.
When you write data to a data set, SAS transcodes the data from the
session encoding to the specified encoding.
By default, encoding
for input processing is determined as follows:
-
If the session encoding and the
encoding that is specified in the file are different, SAS transcodes
the data to the session encoding.
-
If a file has no encoding specified,
but the file's data representation is different from the encoding
of the current session, then SAS transcodes the data to the current
session.
By default, encoding
for output processing is determined as follows:
-
Data is written to a file using
the encoding of the current session, except when a different output
representation is specified using the OUTREP= data set option, the
OUTENCODING= option in the LIBNAME statement, or the ENCODING= data
set option.
-
If a new file replaces an existing
file, then the new file inherits the encoding of the existing file.
-
If an existing file is replaced
by a new file that was created under a different operating environment
or that has no encoding specified, the new file uses the encoding
of the current session.
Note: Character metadata and data
output appears garbled if you specify a different encoding from where
the data set was created.In this example, the data set to be printed
is internally encoded as ASCII, however the data set option specifies
an EBCDIC encoding. SAS attempts to transcode the data from EBCDIC
to ASCII, but the data is already in ASCII. The result is garbled
data.
data a;
x=1;
abc='abc';
run'
proc print data=a (encoding=”ebcdic”);
run;
Note: The following values for
ENCODING= are invalid: