SAS 9.1.3可以读取带有utf8 BOM的csv文件吗?

发布于 2024-10-09 02:36:36 字数 332 浏览 0 评论 0原文

我在 AIX 5.3 中使用 SAS 9.1.3

我必须使用 SAS 导入 CSV 文件。
CSV 的第一行是列名称。
SAS 在日志中报告错误。

然后,我发现CSV文件有3个字符
(这是utf8字节顺序标记)。
在文件的最开头。

我尝试使用:

filename XXX 'XXXXXXXXXX' BOM ;  

但是,这是语法错误。

我用BOMFILE替换BOM,仍然语法错误。

SAS 9.1.3 似乎无法识别 BOM 选项。

有人有类似的经历吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绅士风度i 2024-10-16 02:36:36

您可以尝试如下所示的数据步骤,而不是导入过程:

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;

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;
凤舞天涯 2024-10-16 02:36:36

SAS 可以读取此内容(至少 9.1 以上),但您的 SAS 会话必须使用 DBCS 和编码选项集运行。

-DBCS
-encoding UTF-8

这些需要位于 sasconfig 文件中或调用的命令行上。使用这些选项时,SAS 会话的默认编码是 Unicode。如果没有它,Unicode 选项会通过语法检查,但不会产生任何效果。

您可以尝试使用encoding= options infile 语句,但对我来说从未起作用。
有关一些相关信息,另请参阅 http://www.phuse.eu/download .aspx?type=cms&docID=3658

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文