使用 UTF-8 会话编码与 Latin1 的 SAS ODS Excel
SAS ODS Excel with UTF-8 session encoding vs. Latin1
自从 运行 我的 SAS 基本程序在新的 UTF-8
编码环境下运行后,我在通过 ODS excel
导出数据时遇到了 大量 性能问题。
为给定数据集导出超过 N 条记录通常会导致 SAS 会话冻结,需要我重新启动客户端。
这是我用于测试的内容,使用标准数据集并创建一个小型 xlsx 文件 (<1MB):
data test03;
set sashelp.zipcode;
if _N_ le 3000 then output;
run;
goptions device=png;
ods results=off;
ods excel
file = "/sas_p/gridshared/ch/eg_data/regel/group_hr/export/ods_export.xlsx"
options( flow = "tables" start_at = "A1" embedded_titles= "yes");
proc print data=test03 label noobs;
run;
ods _all_ close;
我逐渐增加_N_
(第3行),在cpu的时间得到相应的增加。然而,超过某个点(通常在大多数数据集的 4 位数范围内)程序就会卡住。
对于上面的例子:
_N_ = 1000 rec → 00:00:09
_N_ = 2000 rec → 00:00:18
_N_ = 3000 rec → timeout
在旧的 latin1
编码环境中存在 none 的行为,其中导出上述 table 的所有 40k 条记录没有任何问题。
关于如何解决这个问题有什么想法吗?
如果您在会话中强制数据集编码为 wlatin1
并且 ods 输出也为 wlatin1
会怎样?
data test03(encoding='wlatin1');
set sashelp.zipcode;
if _N_ le 3000 then output;
run;
filename excelout "/sas_p/gridshared/ch/eg_data/regel/group_hr/export/ods_export.xlsx"
encoding='wlatin1'
;
goptions device=png;
ods results=off;
ods excel
file = excelout
options(flow = "tables" start_at = "A1" embedded_titles= "yes")
;
ods excel close;
自从 运行 我的 SAS 基本程序在新的 UTF-8
编码环境下运行后,我在通过 ODS excel
导出数据时遇到了 大量 性能问题。
为给定数据集导出超过 N 条记录通常会导致 SAS 会话冻结,需要我重新启动客户端。
这是我用于测试的内容,使用标准数据集并创建一个小型 xlsx 文件 (<1MB):
data test03;
set sashelp.zipcode;
if _N_ le 3000 then output;
run;
goptions device=png;
ods results=off;
ods excel
file = "/sas_p/gridshared/ch/eg_data/regel/group_hr/export/ods_export.xlsx"
options( flow = "tables" start_at = "A1" embedded_titles= "yes");
proc print data=test03 label noobs;
run;
ods _all_ close;
我逐渐增加_N_
(第3行),在cpu的时间得到相应的增加。然而,超过某个点(通常在大多数数据集的 4 位数范围内)程序就会卡住。
对于上面的例子:
_N_ = 1000 rec → 00:00:09
_N_ = 2000 rec → 00:00:18
_N_ = 3000 rec → timeout
在旧的 latin1
编码环境中存在 none 的行为,其中导出上述 table 的所有 40k 条记录没有任何问题。
关于如何解决这个问题有什么想法吗?
如果您在会话中强制数据集编码为 wlatin1
并且 ods 输出也为 wlatin1
会怎样?
data test03(encoding='wlatin1');
set sashelp.zipcode;
if _N_ le 3000 then output;
run;
filename excelout "/sas_p/gridshared/ch/eg_data/regel/group_hr/export/ods_export.xlsx"
encoding='wlatin1'
;
goptions device=png;
ods results=off;
ods excel
file = excelout
options(flow = "tables" start_at = "A1" embedded_titles= "yes")
;
ods excel close;