Custom Style Templates: Start Small

综合技术 2018-05-23 阅读原文

I will admit that I was intimidated by PROC TEMPLATE when I first started diving into the Output Delivery System (ODS) world. I was told that I needed to create a custom style template to get the stylized output that I wanted, but I did not know where to begin. PROC TEMPLATE contains many style elements and style attributes and I did not know what went where. The further I got into ODS and PROC TEMPLATE the more comfortable I got. And you will too.

To begin learning about custom style templates I recommend that you:

  • Determine the default style template for the destination you use the most, PDF, HTML, etc. The documentation contains a table with the default style template and recommended SAS-supplied style templates for each ODS destination.
  • Choose the procedure (or two) that you use the most and write a step that includes most of the features of that procedure that you use on a regular basis.
  • Make one small attribute change at a time and run your test program to see what changed.

Working through these recommendations for PROC REPORT, I searched the documentation and found a section on the style elements used by the procedure . The main style elements for PROC REPORT are Header and Data. The Table, DataEmphasis, and LineContent style elements are used as well. I use the ODS PDF destination a lot and I know the default style template for PDF in SAS 9.4 is Styles.Pearl.

In my test program the PROC REPORT step has multiple columns, a summary row, and a line of text. The PROC TEMPLATE code makes one change to the header style element and one change to the data style element. The new style template, named styles.pdfrep, is referenced in the ODS PDF statement.

proc template;
define style styles.pdfrep;
	class data /
	class header /
ods pdf file="test.pdf" style=styles.pdfrep;
proc report;
	column origin type invoice msrp;
	define origin / group;
	define type / group;
	break after origin /summarize;
	compute before origin;
		line origin $10. 'Section';
ods pdf close;

The resulting table has a larger font size for the header section of the table and a background color for the data rows of the table.

This example is small and makes changes to just two style attributes. PROC TEMPLATE can do a lot more and you can create a custom style template with many more customizations. The full list of attributes that can be changed are in this Style Attributes Table . Try any of the attributes that you think you need to get the output that you want. I recommend using bright colors, thick borders, and large font sizes to be sure you can clearly see if the change was made. Once you know you are changing the right place you can then change the values to more desirable colors and sizes.

For more examples of controlling styling in PROC REPORT tables in the common ODS destinations, check out my book The SAS® Programmer's PROC REPORT Handbook: ODS Companion .




display only first div tag inside main div I have four div tags. One of them is .main div. The rest of the are inside .main with .sub classes. What...
Recent climate assessment report – why “I don’t be... The US recently released the National Climate Assessment. When asked about it, Trump said he had only read "some&q...
移动端布局适配方案 rem 做盒子的宽度, viewport 缩放 head 加入常见的 meta 属性 把这段代码加入 head 中的 script 预...
What Every Web Designer Needs to Know About HTML T... Reading Time: 12 minutes HTML tables are here from the early days of the web. According to some source...
media queries for mobile optimisation I've added the following to my site to target phones/tabets etc:The stylesheets clearly work as they...