Changing session character encoding from wlatin1 to utf-8

Reply
Contributor
Posts: 22

Changing session character encoding from wlatin1 to utf-8

Hi,

I have a problem importing a delimited text file into SAS. I get an error message about invalid string. I have seen that one sollution of this problem could be to change the session character encoding in SAS from wlatin1 to utf-8. I have tried to change the sasv9.cfg file line "-ENCODING wlatin1" to "-ENCODING utf-8", but this is not working. Infact nothing is working after that change, error message about connection failure to local server is given. How do I change the session character encoding?

Thank you for any help!

Super User
Posts: 7,762

Re: Changing session character encoding from wlatin1 to utf-8

Posted in reply to peter_sjogarde

Since you could change the sasv9.cfg file, you have direct access to wherever the SAS system is installed. I recommend starting SAS from the commandline and watch what happens (error message(s)).

I suspect that you have SBCS SAS installed, which cannot handle utf-8. You will need to install DBCS SAS.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 3,212

Re: Changing session character encoding from wlatin1 to utf-8

Posted in reply to KurtBremser

Most recent versions of SAS (desktop) are installing the SBCS and DBCS alongside. The only change using the correct entrypoint to start. 
Check that as the old approach of changing config-files should be avoided to the minimum. Then sbcs start is pointing to an  ..\en\..  naming and there should be one similar with an ..\u8\...
When that is not there only the SBCS has been installed and a reinstall with u8 is needed.

---->-- ja karman --<-----
Frequent Contributor
Posts: 134

Re: Changing session character encoding from wlatin1 to utf-8

Posted in reply to peter_sjogarde

Be careful, in order to natively process SAS tables encoded in UTF-8 (or UTF-16), you need to use another sas launcher, which means another SAS engine & another character functions (KSCAN , KSUBSTR etc.).

http://support.sas.com/resources/papers/92unicodesrvr.pdf

Unfortunately, SAS Foundation is installed in dual mode ISO (default) and UTF (called DBCS). Starting with DBCS has strong implications further.

for instance, on Linux, the command line to lauch SAS DBCS with UTF-8 is the following :

$SASROOT/SASFoundation/9.2/bin/sas_u8 -encoding utf-8

Back to your problem, using a Unicode SAS session might be unnecessary. You can try, in your default SAS (ISO) session assigning your Filename with the option ENCODING=utf8.

SAS can transcode UTF to ISO (e g WLATIN1) at the import step and let you then code as usual. The target tables are then stored in ISO (WLATIN1), of course.

FILENAME myfile 'my pathname' ENCODING=utf8;

Ask a Question
Discussion stats
  • 3 replies
  • 4547 views
  • 0 likes
  • 4 in conversation