Options for Commands, Statements, and Procedures for NLS |
Valid in: | %INCLUDE statement; FILE statement; FILENAME statement; FILENAME statement, EMAIL (SMTP) Access Method; INFILE statement; ODS statements; FILE command; INCLUDE command |
%INCLUDE statement: | Reads SAS statements and data lines from the specified source file |
Category: | Data Access |
%INCLUDE statement-specific: | Is not supported under z/OS |
FILE statement: | Writes to an external file |
FILENAME statement: | Reads from or writes to an external file |
FILENAME statement, EMAIL (SMTP) Access Method: | Sends electronic mail programmatically from SAS using the SMTP (Simple Mail Transfer Protocol) |
INFILE statement: | Reads from an external file |
ODS statements: | Controls features of the Output Delivery System that are used to generate, store, or reproduce SAS procedure and DATA step output |
FILE command: | Saves the contents of a window to an external file |
INCLUDE command: | Copies an external file into the current window |
Syntax |
ENCODING= 'encoding-value' |
Options |
specifies the encoding to use for reading, writing, copying, or saving an external file. The value for ENCODING= indicates that the external file has a different encoding from the current session encoding.
When you read, write, copy, or save data using an external file, SAS transcodes the data from the session encoding to the specified encoding.
For details, see SBCS, DBCS, and Unicode Encoding Values for Transcoding Data.
Default: | SAS uses the current session encoding. |
Examples |
This example creates an external file from a SAS data set. The current session encoding is Wlatin1, but the external file's encoding needs to be UTF-8. By default, SAS writes the external file using the current session encoding.
To specify what encoding to use for writing data to the external file, specify the ENCODING= option:
libname myfiles 'SAS data-library'; filename outfile 'external-file'; data _null_; set myfiles.cars; file outfile encoding="utf-8"; put Make Model Year; run;
When you tell SAS that the external file is to be in UTF-8 encoding, SAS then transcodes the data from Wlatin1 to the specified UTF-8 encoding.
This example creates a SAS data set from an external file. The external file is in UTF-8 character-set encoding, and the current SAS session is in the Wlatin1 encoding. By default, SAS assumes that an external file is in the same encoding as the session encoding, which causes the character data to be written to the new SAS data set incorrectly.
To specify which encoding to use when reading the external file, specify the ENCODING= option:
libname myfiles 'SAS data-library'; filename extfile 'external-file' encoding="utf-8"; data myfiles.unicode; infile extfile; input Make $ Model $ Year; run;
When you specify that the external file is in UTF-8, SAS then transcodes the external file from UTF-8 to the current session encoding when writing to the new SAS data set. Therefore, the data is written to the new data set correctly in Wlatin1.
This example creates an external file from a SAS data set. By default, SAS writes the external file using the current session encoding. The current session encoding is Wlatin1, but the external file's encoding needs to be UTF-8.
To specify which encoding to use when writing data to the external file, specify the ENCODING= option:
libname myfiles 'SAS data-library'; filename outfile 'external-file' encoding="utf-8"; data _null_; set myfiles.cars; file outfile; put Make Model Year; run;
When you specify that the external file is to be in UTF-8 encoding, SAS then transcodes the data from Wlatin1 to the specified UTF-8 encoding when writing to the external file.
This example illustrates how to change text encoding for the message body as well as for the attachment.
filename mymail email 'Joe.Developer@sas.com'; data _null_; file mymail subject='Text Encoding' encoding=greek 1 attach=('C:\My Files\Test.out' 2 content_type='text/plain' encoding='ebcdic1047' outencoding='latin1'); 3 run;
In the program, the following occurs:
The ENCODING= e-mail option specifies that the message body will be encoded to Greek (ISO) before being sent.
For the ATTACH= e-mail option, the attachment option ENCODING= specifies the encoding of the attachment that is read into SAS, which is Western (EBCDIC).
Because SMTP and other e-mail interfaces do not support EBCDIC, the attachment option OUTENCODING= converts the attachment to Western (ISO) before sending it.
This example creates a SAS data set from an external file. The external file's encoding is in UTF-8, and the current SAS session encoding is Wlatin1. By default, SAS assumes that the external file is in the same encoding as the session encoding, which causes the character data to be written to the new SAS data set incorrectly.
To specify which encoding to use when reading the external file, specify the ENCODING= option:
libname myfiles 'SAS data-library'; filename extfile 'external-file'; data myfiles.unicode; infile extfile encoding="utf-8"; input Make $ Model $ Year; run;
When you specify that the external file is in UTF-8, SAS then transcodes the external file from UTF-8 to the current session encoding when writing to the new SAS data set. Therefore, the data is written to the new data set correctly in Wlatin1.
See Also |
Statements:
| |||||||||||||||||
Commands:
|
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.