BookmarkSubscribeRSS Feed
peter_sjogarde
Fluorite | Level 6

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!

3 REPLIES 3
Kurt_Bremser
Super User

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.

jakarman
Barite | Level 11

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 --<-----
ronan
Lapis Lazuli | Level 10

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 12641 views
  • 0 likes
  • 4 in conversation