2

I currently have an xlsx file with thai characters in it which is correctly displayed in excel.

thai character displayed in excel

However when I import this file in SAS EG 4.3 (Also tried in 5.1) the thai characters are displayed as "???"

After Import in SAS

Here is the sample code for the same

DATA WORK.pthai;
LENGTH F1 $4 ;
FORMAT F1 $UTF8X4. ;
INFORMAT F1 $UTF8X4. ;
INFILE 'C:\Users\rohit_000\AppData\Local\Temp\SEG12960\pthai-507bc48108424b79810743ea724b0861.txt'
    LRECL=4
    ENCODING="WLATIN1"
    TERMSTR=CRLF
    DLM='7F'x
    MISSOVER
    DSD ;
INPUT F1 : $UTF8X4. ;
RUN;

I have also tried all sorts of encoding and I also encountered an error saying cannot covert to wlatin1 from utf-16le.

Is there any way how I can get this character to display in SAS Tables?

kl78
  • 1,628
  • 1
  • 16
  • 26
Rohit Acharya
  • 47
  • 1
  • 7
  • i am wondering, you have an excel, put you are importing a text file in your code. – kl78 Oct 15 '15 at 09:42
  • I was experimenting with various options, so i tried getting the data inside by using a txt – Rohit Acharya Oct 15 '15 at 10:54
  • 1
    There is a encoding for Thai, see this table: http://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/viewer.htm#a002607278.htm But I never used it, i guess you have to test if this works. – kl78 Oct 15 '15 at 11:34
  • hey kl78 thanks for the quick response, i tried all the thai enconding in the list but in no vain, I get garbage values entered and each time its different for e.g. DATA WORK.pthai21; LENGTH F1 $ 4 ; FORMAT F1 $CHAR4. ; INFORMAT F1 $CHAR4. ; INFILE 'C:\Users\rohit_000\Desktop\pthai.xlsx' LRECL=4 ENCODING="ebcdic838" TERMSTR=CRLF DLM='7F'x MISSOVER DSD ; INPUT F1 : $CHAR4. ; RUN; I got http://screencast.com/t/Lw49Obd4AoU – Rohit Acharya Oct 15 '15 at 11:42
  • 1
    What encoding are you _running_ SAS in? And Windows? – Joe Oct 15 '15 at 14:01
  • You could try to use encoding="utf-8" option at infile, if your SAS encoding system is wlatin1. – Shenglin Chen Oct 15 '15 at 18:49
  • when I try the utf-8 encoding I get the following error ERROR: Invalid string. FATAL: Unrecoverable I/O error detected in the execution of the DATA step program. Aborted during the EXECUTION phase. – Rohit Acharya Oct 16 '15 at 03:44

1 Answers1

1

I believe your SAS session has to be using the correct encoding. If you open the sasv9.cfg file in the same directory as your sas.exe file, you will see the following line:

-config "C:\Program Files\SASHome\SASFoundation\9.4\nls\en\sasv9.cfg"

change the "en" to "u8" and re-open SAS and import the file.

In general it's not a good habit to stay in u8, as it can prevent other users from opening SAS datasets with utf-8 encoding.

Sarah Hailey
  • 494
  • 5
  • 19