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;
	parent=styles.pearl;
	class data /
		backgroundcolor=lightcyan;
	class header /
		fontsize=18pt;
end;
run;
 
ods pdf file="test.pdf" style=styles.pdfrep;
proc report data=sashelp.cars;
	column origin type invoice msrp;
	define origin / group;
	define type / group;
 
	break after origin /summarize;
	compute before origin;
		line origin $10. 'Section';
	endcomp;
run;
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 .

SAS博客

责编内容by:SAS博客 (源链)。感谢您的支持!

您可能感兴趣的

Is it possible to let a user modify elements of an... Say a user was viewing a webpage with some content like some text Is there any way to allow them to change the contents to new text and commit...
Pixel sorting study When working on Glitchy Checkers , my futuristic checkers game for iOS, I became interested in pixel sorting — a moderately popular technique of tran...
Web Design Weekly #278 Headlines Developing As A Developer A really solid post that is aimed at new developers but highly applicable for all in my eyes. The post...
Add HTML to HTML string in jQuery I have a HTML string and I want to append another html string to this in some arbitrary location. Example: var htmlString = ' Hello 'var ap...
Storing the Html form information in a JS table body{padding-top:50px;}.starter-template{padding:40px 15px;text-...