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

我正在试图产生下面两个工作表“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; 

您需要每个proc print语句的ods excel options语句:

 /* 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; 

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