1
votes

I am using SAS 9.1.3 in AIX 5.3

I have to proc import a CSV file using SAS.
The first line of CSV are column names.
SAS reports error in the log.

Then, I find out that the CSV file has 3 characters
(which is the utf8 byte order mark).
at the very beginning of the file.

I tried to use :

filename XXX 'XXXXXXXXXX' BOM ;  

But, this is syntax error.

I replace BOM with BOMFILE, still syntax error.

It seems that SAS 9.1.3 cannot recognize the BOM options.

Does anyone have similar experience ?

2
Try runsubmit.com - it's like StackOverflow but just for SAS.Robert Penridge

2 Answers

0
votes

Instead of the import procedure, you might try a data step like the following:

data test;
  infile "data.csv" firstobs=2 dlm=',';   /* assuming delimiter is a comma */
  input                                   /* use Input with $UTF8Xw. informat */
     field1 $utf8x3.                      /* input fields 1 through 3  */
     field2 $utf8x10.
     field3 $utf8x3.
  ;
  run;
0
votes

SAS can read this (at least 9.1 plus) but your SAS session must be running with the DBCS and encoding options set.

-DBCS -encoding UTF-8

These need to be in the sasconfig file or on command line of invocation. With these options the default encoding is Unicode for the SAS session. Without it Unicode options pass syntax checks but have no effect.

You can try using the encoding= options infile statement but for me that never worked. For some related info see also http://www.phuse.eu/download.aspx?type=cms&docID=3658