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 .




Space between two divs My issue is that I have two (or more) divs of the same class, that need to be spaced from each other. I cannot directly use margins however, as the la...
Override internal stylesheet with external stylesh... I use Joomla 2.5 and I'd like to override the features of a module which's CSS is actually embedded within the tag of the html pages the module is on...
Why you should never use Html.Raw in your Razor vi... Earlier today, Microsoft released two security advisories for vulnerabilities I discovered in the ASP.NET Core 2.0 VS2017 templates and reported l...
HTML for sprites So I've setup Compass for creating automatic sprites with SCSS . All goes well, it generates some nice CSS for me :- .icons-sprite,...
Detecting an html button click with node.js? I'm quite new to node.js , so my apologies if this is a potentially stupid question. I'm aware that when a new page is requested, it triggers a ...