BookmarkSubscribeRSS Feed
RaSha
Calcite | Level 5

Hey There,

I am trying to read a column holding Japanese character from an excel sheet via infile or proc import statement but getting boxes in output. Tried to convert input sheet to unicode txt and UTF-8 csv but no luck.  Current system encoding is Latin1 western (ISO). Appreciate your help. Many thanks

 

Sample code - 

filename temp '<location>/Bookutf8.csv' encoding='UTF-8';
data test;
infile temp dlm=',' dsd firstobs=2 encoding='utf-8' 
input variable1 $ variable2 $;
run;

5 REPLIES 5
andreas_lds
Jade | Level 19

If the data contains chars that don't exist in Latin1, you must change the encoding of you sas-session to read the data properly.

RaSha
Calcite | Level 5
Hi.. Thanks for your reply..

I tried to use encoding statement in data step but it didn't work and I also tried to add the statement in configuration file. After which the metadata server threw errors and didn't connect ..

Any sample code which you can suggest may work?

Thanks in advance
RaSha
Calcite | Level 5

Hi.. Thanks for your reply..

I tried to use encoding statement in data step but it didn't work and I also tried to add the statement in configuration file. After which the metadata server threw errors and didn't connect ..

Any sample code which you can suggest may work?

Thanks in advance

Tom
Super User Tom
Super User

If your SAS session is running using a single byte encoding, like WLATIN1, then there are only 256 possible characters it can represent. And none of them are Japanese characters.

 

You probably need to change the encoding for the whole SESSION, not just how this one file is being read.  That must be done when you start SAS, you cannot do it in the program itself.  

 

Check with your local SAS support how you can start SAS using UTF-8 encoding or UNICODE support.  If you are running SAS Display Manager then your typically use a different command (or click on a different ICON in Windows).  If you are using Enterprise Guide or SAS/Studio you connect to a different SAS application server.

 

ChrisNZ
Tourmaline | Level 20

I can't verify as my session is UTF8, but try to set the dataset's encoding to UTF8, like you did for the filename.

You won't be able to display the Japanese characters in your wlatin1 SAS session though.

Also check that the variable lengths are sufficient for storing multi-byte characters.

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 5 replies
  • 3428 views
  • 1 like
  • 4 in conversation