PROC TEMPLATE

Basic concepts

Christian Baghai
3 min readJan 5, 2023

In SAS, PROC TEMPLATE is a procedure that enables you to create and modify templates for output delivery system (ODS) destination styles, report templates, and stored process templates.

A template is a type of SAS program that defines a layout or format for the output that is produced by an ODS destination, report, or stored process. When you create a template, you can specify the overall layout, as well as the characteristics of individual elements, such as fonts, colors, and sizes.

To use PROC TEMPLATE, you must first create a template store, which is a SAS library or a directory in which you can save templates. You can then use the TEMPLATE statement to create a new template, or use the MODIFY statement to modify an existing template.

Here is an example of how to create a new template using PROC TEMPLATE:

Cproc template;
define style MyStyle;
parent=Styles.HtmlBlue;
/* Modify style characteristics here */
end;
run;

This creates a new style called “MyStyle” based on the HtmlBlue style, which is a predefined style that is shipped with SAS. You can then use this style in your ODS output by specifying the STYLE= option in the ODS statement, like this:

ods html style=MyStyle;
/* your SAS code goes here */
ods html close;

What are the possibilities of proc template in SAS

PROC TEMPLATE enables you to create and modify templates for three types of objects in SAS: output delivery system (ODS) destination styles, report templates, and stored process templates.

Here are some of the possibilities for using PROC TEMPLATE:

  1. Defining the layout and formatting for ODS destination styles: ODS is a SAS system that enables you to produce output in a variety of formats, such as HTML, PDF, Excel, and RTF. You can use PROC TEMPLATE to create custom styles that define the appearance of your output, such as fonts, colors, and sizes.
  2. Creating report templates: Report templates enable you to define the layout and formatting for reports that are generated by SAS. You can use PROC TEMPLATE to create templates that specify the overall structure of the report, as well as the characteristics of individual elements, such as titles, footnotes, and page numbers.
  3. Modifying stored process templates: Stored processes are SAS programs that are saved on a server and can be executed by multiple users. You can use PROC TEMPLATE to modify the templates that are used to generate the output for stored processes.

In addition to these possibilities, you can also use PROC TEMPLATE to customize the appearance of other types of SAS output, such as the output from PROC REPORT and PROC TABULATE.

Is there any other solution to format ODS in SAS other than PROC TEMPLATE?

Yes, there are a few other options for formatting ODS output in SAS. Here are a few alternatives to PROC TEMPLATE:

  1. Using ODS options and statements: You can use the options and statements of the ODS system to control the appearance of your output. For example, you can use the STYLE= option to specify a predefined ODS style, such as HTMLBLUE or JOURNAL. You can also use options such as BODYTITLE and FOOTNOTE to specify the characteristics of individual elements of your output.
  2. Using SAS graphics templates if you are working on a chart: You can use SAS graphics templates to define the appearance of graphs and charts that are produced by SAS procedures. Graphics templates enable you to specify the characteristics of elements such as titles, labels, and legends.
  3. Using the Output Delivery System: The Output Delivery System (ODS) is a SAS system that enables you to produce output in a variety of formats, such as HTML, PDF, Excel, and RTF. You can use the ODS system to customize the appearance of your output by creating custom styles or modifying existing styles.

Is it possible to change style in proc template in SAS

Yes, it is possible to change the style in a PROC TEMPLATE in SAS. PROC TEMPLATE enables you to create and modify templates for output delivery system (ODS) destination styles, report templates, and stored process templates. A template is a type of SAS program that defines a layout or format for the output that is produced by an ODS destination, report, or stored process.

To change the style in a PROC TEMPLATE, you can use the MODIFY statement to modify an existing template. For example, the following code modifies the MyStyle template to change the font size:

proc template;
modify style MyStyle;
fontsize=12pt;
end;
run;

You can also use the RESET statement to remove all changes that have been made to a template and restore it to its original state. For example:

proc template;
reset style MyStyle;
run;

--

--

Christian Baghai
Christian Baghai

No responses yet