Customize the appearance of the report produced in Example 4.2 by modifying style attributes with ODS. Send the output to a nonlisting destination.
Client Protocol Population | ||||
Table 2.14 | ||||
Baseline Demographics | ||||
Active | Placebo | |||
Number of Patients | 94 | 106 | ||
Gender | ||||
Male | 41 (21%) | 46 (23%) | ||
Female | 53 (27%) | 60 (30%) | ||
Age (years) | ||||
Mean (SEM) | 52.1 (1.96) | 53.9 (1.74) | ||
25th-75th | 33.7 - 67.3 | 37.7 - 69.1 | ||
Mm - Max | 21.0-84.7 | 20.5-84.8 | ||
No. Missing | 0 | 0 | ||
Race | ||||
Non-White | 37 (19%) | 33 (17%) | ||
White | 57 (29%) | 73 (37%) | ||
Height (inches) | ||||
Mean (SEM) | 65.4 (0.54) | 65.4 (0.54) | ||
25th - 75th | 61.5 - 69.9 | 60.5 - 70.0 | ||
Mm - Max | 55.3 - 74.8 | 55.2 - 74.7 | ||
No Missing | 0 | 0 | ||
Weight (lbs) | ||||
Mean (SEM) | 188.2 (5.07) | 191.1 (4.43) | ||
25th - 75th | 140.9-225.8 | 159.2-223.7 | ||
Min - Max | 110.5-275.6 | 110.4-277.0 | ||
No Missing | 0 | 0 |
Data Set | DEMOG |
Report Example | Example 4.2 |
Preparatory Steps | PROC FREQ
PROC MEANS PROC SORT PROC TRANSPOSE DATA steps |
Featured Steps and Statement | PROC TEMPLATE
DATA step ODS statement |
Featured Step Statements and Options | PROC TEMPLATE statements:
DATA step: FILE PRINT ODS statement ODS ESCAPECHAR= Inline formatting |
Additional Features | DATA step programming |
Output Destination of Example | RTF |
A Closer Look | Comparing DATA Steps That Send and Do Not Send Output to ODS Learning More about ODS Inline Formatting |
Other Examples That Use This Data Set | Example 4.2 |
The report in Example 4.2 presents statistics in a customized format that cannot be produced easily by a SAS procedure. The program in Example 4.2 uses a DATA step to write the summary statistics produced by PROC FREQ and PROC MEANS, which were saved in several output data sets.
Example 4.2 is a tabular summary report. It has titles and three columns. The first column lists the demographic categories. The second and third columns contain the statistics for the two groups, “Active” and “Placebo,” for each of the categories.
The report in this example takes advantage of the tabular structure of the Example 4.2 report and adds ODS features to the program to send the report to a nonlisting destination.
This program uses the same summary statistics data sets that PROC FREQ and PROC MEANS created in Example 4.2. Rather than processing the data sets in the DATA step as in Example 4.2, this program combines the summary statistic data sets into one data set. It sorts and restructures the observations in this new data set to fit the three-column format of the report. The primary purpose of the DATA _NULL_ step in this example is to send the three-column report to the output destination. The DATA step does minimal processing of the observations.
The FILE statement in the DATA step directs SAS to use a table definition to construct the report. A PROC TEMPLATE step before the DATA step creates the table definition. This table definition is saved in a template store and can be reused. The table definition defines three columns and some of the style attributes of these columns. The PROC TEMPLATE step also defines some of the style attributes of the headers in the table.
The FILE statement and the PUT statements in the DATA step communicate instructions to ODS. The FILE statement includes options that are specific to sending data to an ODS destination. The PUT statements write to the columns of the report and have a different syntax than in Example 4.2.
Specific formatting instructions for the titles and demographic categories are embedded in text strings. Instructions are preceded by a symbol defined with the ODS ESCAPECHAR= statement. This symbol followed by an “S” triggers ODS to intrepret the information that follows as instructions to set style attributes for the text that follows.
A Closer Look |
The DATA step in this program uses FILE and PUT statements to create the report. Example 4.2 also uses FILE and PUT statements to create its report. However, the syntax of these two statements in Example 4.2 is different from that in this example.
The program in Example 4.2 directs the placement of information on the page by computing and designating column and row positions. The PUT statement uses line control pointers and column control pointers to move a pointer to a specific byte location on a page.
The column pointers in this example’s program, however, do not explicitly direct output to a column character location. The direction is instead to an entire column. “Column” means something different when using ODS in the DATA step:
□ | When you specify FILE PRINT, an “@3” moves the line pointer to byte location 3. |
□ | When you specify FILE PRINT ODS, an “@3” moves the line pointer to what ODS considers the third column of data in the tabular layout of the report. |
The FILE statement with the ODS option and ODS suboptions controls different features than the FILE PRINT statement does. It tells SAS to bind the data component of your report to a table definition (template). In this example, this results in an RTF report whose basic structure is controlled by the SASUSER.DEMOG table definition.
The suboptions on the FILE PRINT ODS statement specify the table definition, and they associate variable names in the data set to columns in the table definition.
Since the likely reason you’re using ODS in a DATA step is because you need to prepare a highly formatted report, it would not be sensible to point to specific column and row locations as in Example 4.2. The software that manages your output destination would do a better job at positioning your data. For example, when you use a proportional font such as Times Roman, characters have different widths. Directing output to a specific byte location would cause strange looking results, with some characters surrounded by excess space and others running into other characters. The output in the “A Closer Look” section of Example 6.2 illustrates what happens when you try to explicitly position data when using a proportional font.
This example shows how you can insert formatting instructions within text strings. These instructions temporarily override existing instructions that are provided by the template.
To use ODS inline formatting, first submit the ODS ESCAPECHAR= statement to define an escape character that SAS will interpret as a trigger for inline formatting. Be sure that the character you pick will not be in your text. This example specified the caret (^).
Once the escape character has been defined, you can insert formatting instructions in your report. Following the escape character is the type of instruction, an equal sign, and the instructions enclosed in brackets. This example specified style-type instructions, and style is represented as “S.” The instructions remain in effect until the end of the text string, unless another instruction is encountered in the same text string.
If you want to revert to the original style of the text string after applying an inline formatting instruction, you can terminate the instruction as shown in the following TITLE statement. The text “Baseline Demographics” is printed with font size of 22 pt, whereas the remaining text in the title is printed in the font size that was in effect before the 22 pt attribute specification.
title '^S={font_size=22pt}Baseline Demographics^S={} (collected at initial visit)';
The syntax of the style attribute specifications is similar to that for style attributes in table definitions, PROC PRINT, PROC REPORT, and PROC TABULATE. For further examples of specifying style attributes, look at the other examples in this chapter, all of which use one of these four processes. For more detailed information, see SAS 9.1 Output Delivery System: User’s Guide and Base SAS 9.1 Procedures Guide (support.sas.com/v9doc).
There are additional instruction types that can be specified to do actions such as starting new lines, wrapping lines, and so on. Please refer to the SAS online documentation for this information (support.sas.com/v9doc).
3.136.22.50