sas ods excel不能生成多个工作表

时间:2017-03-14 17:40:22

标签: excel sas

我试图制作以下两个工作表" woe_con_out"和" woe_cat_out"进入同一个excel" woe_summary.xlsx"。但是在运行此代码之后,只生成了一个工作表(woe_cat_out)。我哪里做错了?

data translate;
format report $256.;
infile "out_con.out" dlm='09'x dsd;
input report $;
run;

ods excel file="woe_summary.xlsx" style = printer options(sheet_name = "woe_con_out") ;
proc print data = translate noobs
style(data) = {font_face = "courier_new" font_size = 11pt}
style(column) = {width = 1000%};
run;
ods excel close;

data translate;
format report $256.;
infile "out_cat.out" dlm='09'x dsd;
input report $;
run;

ods excel file="woe_summary.xlsx" style = printer options(sheet_name = "woe_cat_out") ;
proc print data = translate noobs
style(data) = {font_face = "courier_new" font_size = 11pt}
style(column) = {width = 1000%};
run;
ods excel close;

1 个答案:

答案 0 :(得分:2)

对于每个ods excel options语句,您需要proc print个语句:

/* first ods excel statement includes the file and style */
ods excel file="C:\desktop\woe_summary.xlsx" style = printer;

/* include ods excel options sheet_name for each PROC PRINT statement */
ods excel options(sheet_name = "woe_con_out");
proc print data = sashelp.class noobs;
var _all_;
run;

/* same as above -- include ods excel options sheet_name for each PROC PRINT statement */
ods excel options(sheet_name = "woe_cat_out"); 
proc print data = sashelp.fish noobs;
var _all_;
run;

/* close your ods excel engine */
ods excel close;

此外,在您的情况下,我会创建两个translate数据集,即translate_contranslate_cat,因此您不会覆盖它们并能够使用所述方法。