如何通过proc报告在excel中添加单元格

时间:2012-09-05 12:20:08

标签: sas

ods listing close;
ods tagsets.excelxp file='Y:\fonts\CC_ACQ_fonts_v2_har.xls' style=sasweb
options(sheet_name="CC_ACQ_JUN12_V2");
proc report data=work.matrix_input nowd
 style(report)={font_face=times font_size=1 font_weight=bold bordercolor=black}
 style(header)={font_face="Times New Roman" font_size=8pt  font_face=times    cellwidth=1in background=gray foreground=black font_weight=bold bordercolor=black  }
 style(column)={font_face="Times New Roman" font_size=8pt 
         just=center cellheight=15in font_face=times};
 column CELL offer_description pop product;
 run;
ods tagsets.excelxp close;
ods listing;

知道excel中的第一列是CELL知道上面的CELL(列名)我想写BY:CELL(在另一个单元格中) 以上offer_description pop产品(3栏)以上我想写以TOTAL Consilodate Mail为背景的绿色

1 个答案:

答案 0 :(得分:0)

这应该有效。基本上你使用ACROSS变量获取你的第二个标题,然后你必须放入一个非打印的虚拟列,以使事情表现出来(你不能拥有完全的ACROSS变量)。您可以使用样式语句添加颜色。如果您使用PROC TEMPLATE来定义样式,那么您的代码看起来会更清晰,因此您可以使用样式继承来反复重写样式。

data class;
set sashelp.class;
total='Total Consolidated';
namedummy='By Name';
dummy=' ';
run;

ods listing close;
ods tagsets.excelxp file='c:\temp\test.xml' style=sasweb
options(sheet_name="CC_ACQ_JUN12_V2");
proc report data=class nowd
 style(report)={font_face=times font_size=1 font_weight=bold bordercolor=black}
 style(header)={font_face="Times New Roman" font_size=8pt  font_face=times    cellwidth=1in background=gray foreground=black font_weight=bold bordercolor=black  }
 style(column)={font_face="Times New Roman" font_size=8pt 
         just=center cellheight=15in font_face=times};
 column dummy namedummy,name total,(age height weight);
define total/' ' across style={font_face="Times New Roman" font_size=8pt  font_face=times    cellwidth=1in background=green foreground=black font_weight=bold bordercolor=black };
 define namedummy/' ' across;
 define dummy/noprint;
 run;
ods tagsets.excelxp close;
ods listing;