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.

 

 

 

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