BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma_at_SAS
Lapis Lazuli | Level 10

I guess my SAS session has encoding WLATIN1, while my SAS data file has UTF-8 encoding. I need to change my SAS session's encoding to UTF-8. I tried the following code but did not work. I appreciate it if you may guide me. Thanks!

 

data SAS_data; 
	set name_lib.data;  
	ENCODING='UTF-8'; 
	OPTIONS NOFMTERR; 
	run;
Spoiler
NOTE: Data file name_lib.data.DATA is in a format that is native to another host, or the file encoding does not match the
session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce
performance.

 

Spoiler
ERROR: Some character data was lost during transcoding in the dataset name_lib.data. Either the data contains characters
that are not representable in the new encoding or truncation occurred during transcoding.
proc options option=config; run;
proc options group=languagecontrol; run;
proc options option=encoding; run; 

 

Spoiler
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc options option=config; run;
 
     SAS (r) Proprietary Software Release 9.4  TS1M7
 
  CONFIG=( "C:\SAS\Config\Lev1\SASApp\WorkspaceServer\sasv9.cfg" "C:\SAS\Config\Lev1\SASApp\sasv9.cfg" "C:\Program 
 Files\SASHome\SASFoundation\9.4\sasv9.cfg" "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg" 
 "C:\SAS\Config\Lev1\SASApp\sasv9_usermods.cfg" "C:\SAS\Config\Lev1\SASApp\WorkspaceServer\sasv9_usermods.cfg" )
                    Specifies the configuration file that is used when initializing or overriding the values of SAS system options.
 NOTE: PROCEDURE OPTIONS used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 74         proc options group=languagecontrol; run;
 
     SAS (r) Proprietary Software Release 9.4  TS1M7
 
 
 Group=LANGUAGECONTROL
  DATESTYLE=MDY     Specifies the sequence of month, day, and year when ANYDTDTE, ANYDTDTM, or ANYDTTME informat data is ambiguous.
  DFLANG=LOCALE     Specifies the language for international date informats and formats.
  DSCAS             Runs the DATA step on the CAS server.
  EXTENDOBSCOUNTER=YES
                    Specifies whether to extend the maximum number of observations in a new SAS data file.
  LOCALEDATA=SASLOCALE
                    Specifies the location of the locale database.
  NOLOGLANGCHG      Disables changing the language of the SAS log when the LOCALE= option is changed.
  NOLOGLANGENG      Write SAS log messages based on the values of the LOGLANGCHG, LSWLANG=, and LOCALE= options when SAS started.
  LSWLANG=LOCALE    Specifies the language for SAS log and ODS messages when the LOCALE= option is set after SAS starts.
  MAPEBCDICTOASCII= Specifies the transcoding table that is used to convert characters from ASCII to EBCDIC and EBCDIC to ASCII.
  NONLDECSEPARATOR  Disables formatting of numeric output using the decimal separator for the locale.
  NOODSLANGCHG      Disables changing the language of the SAS message text in ODS output when the LOCALE option is set after start 
                    up.
  PAPERSIZE=LETTER  Specifies the paper size to use for printing.
  RSASIOTRANSERROR  Displays a transcoding error when illegal values are read from a remote application.
  TIMEZONE='GMT-04:00'
                    Specifies a time zone.
  TRANTAB=(lat1lat1,lat1lat1,wlt1_ucs,wlt1_lcs,wlt1_ccl,,,)
                    Specifies the translation table catalog entries.
  URLENCODING=SESSION
                    Specifies whether the argument to the URLENCODE function and to the URLDECODE function is interpreted using the 
                    SAS session encoding or UTF-8 encoding.
  NODBCS            Disables double-byte character sets.
  DBCSLANG=NONE     Specifies a double-byte character set language.
  DBCSTYPE=NONE     Specifies the encoding method to use for a double-byte character set.
  ENCODING=WLATIN1  Specifies the default character-set encoding for the SAS session.
  LOCALE=EN_US      Specifies a set of attributes in a SAS session that reflect the language, local conventions, and culture for a 
                    geographical region.
  NONLSCOMPATMODE   Encodes data using the SAS session encoding.
 NOTE: PROCEDURE OPTIONS used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 75         proc options option=encoding; run;
 
     SAS (r) Proprietary Software Release 9.4  TS1M7
 
  ENCODING=WLATIN1  Specifies the default character-set encoding for the SAS session.
 NOTE: PROCEDURE OPTIONS used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 76         
 77         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 89         

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

If your sas was stand alone PC version . Try Unicode version sas.

x.png

View solution in original post

10 REPLIES 10
japelin
Rhodochrosite | Level 12

Do you need to process UTF-8 encoding data sets within the current session?
The easiest way is to use the SAS Unicode version.

SASKiwi
PROC Star

You just need to add the following line to your file:

C:\SAS\Config\Lev1\SASApp\sasv9_usermods.cfg

 -ENCODING = UTF-8

Emma_at_SAS
Lapis Lazuli | Level 10
Thanks, SASKiwi. How do I exactly add ENCODING = UTF-8 to my file?
Ksharp
Super User

If your sas was stand alone PC version . Try Unicode version sas.

x.png

Emma_at_SAS
Lapis Lazuli | Level 10

Thanks everyone! Using the SAS(Unicode) session was the easiest way I could use to read my whole data. 

 

In this SAS environment (Unicode), I see an extra column as ENCODING (Char). Is everything in this environment work similar to the regular SAS(DBCS) session and saved normally to be used in the other environment later? Is there anything I should be careful about?

 

Thanks! 

Ksharp
Super User
"Is everything in this environment work similar to the regular SAS(DBCS) session "
Yes.

"and saved normally to be used in the other environment later?"
No. only for utf-8 encoding environment .
Emma_at_SAS
Lapis Lazuli | Level 10
"and saved normally to be used in the other environment later?"
No. only for utf-8 encoding environment.
--> So, the code from the SAS(UNICODE) works well for two environments: SAS(UNICODE) and the UTF-8 encoding environment.
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you, everyone! 

Ksharp
Super User
SAS CODE could work at any encoding , But Data does not .
SAS(UNICODE) IS JUST (equal) UTF-8 encoding environment.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 3713 views
  • 3 likes
  • 5 in conversation