sas基础系列(3)-表格标颜色示例 - 高山老王

时间:2024-03-09 19:40:17

以下代码可以直接在SAS执行查看效果

ods path reset;
ods path show;
ods html close;
options nodate;
ods pdf file="ProcOdstableTable.pdf";
title "Using PROC ODSTABLE";

%let color1=#FFFF80; /*淡黄色*/
%let color2=#80FF80; /*浅绿色*/
%let color3=#DBFE8E; /*淡黄绿色*/

proc odstable name=Base.Template.Table;
cellstyle _row_ = 1 && _col_ = 1 as {BackgroundColor=&color1. },
_row_ = 1 && _col_ = 2 as {BackgroundColor=&color2. },
_row_ = 1 && _col_ = 3 as {BackgroundColor=&color3. },
_datatype_ = "num" as {color=red},
_datatype_ = "char" as {color=blue};
run;

proc sql;
select * from sashelp.class;
run;
quit;
proc odstable name=Base.Template.Table store=mystore;

cellstyle _row_ in (16) as {BackgroundColor=Palegreen },
_row_ in (15) as {BorderBottomStyle=Solid },
_row_ in (14) as {BackgroundColor=Limegreen },
mod(_row_,2) as {Background=Honeydew},
_col_ = 1 as {Width=1.2in BorderLeftColor=Black},
_col_ = 2 as {Width=2in},
_col_ = 3 as {Width=.6in},
_col_ = 4 as {Width=.5in},
_col_ = 5 as {Width=.9in};
run;
ods path (prepend) Mystore;
ods path show;
proc sql;
select * from sashelp.class;
run;
quit;

ods pdf close;
ods html;
proc template;
delete base.template.table;
delete base.template.table / store=mystore;
run;

ods path reset;