Thursday, August 20, 2009

Short for style expression

With the power of ODS, we can specify the style elements for specific location, especially for reporting procedure like PROC PRINT, PROC REPORT, PROC TABULATE.
If the style expression is trivial and long, it will be boring to apply same style expression to many reports at one time.

For example:

ods html file="style.html";
proc report data=sashelp.class nowd;
column name age;
define name/display
style(header)=[just=l
foreground=red
cellwidth=2cm]
;
define age / display ;
run;
ods html close;


To avoid typing the same expression again and again, we can customize style using PROC TEMPLATE.

The report above can be converted to:

proc template;
define style styles.mystyle;
parent=default;
style header1 from header /
foreground=red
width=2cm
textalign=left;
end;
run;

ods html file="style2.html" style=mystyle;
proc report data=sashelp.class nowd;
column name age;
define name / style(header) = header1;
define age / display ;
run;

ods html close;

No comments: