Add hyperlinks to elements of a report so that the reader can access additional information related to the report by selecting a hyperlink.
After the reader selects the “Exercise and Lipids Study” hyperlink in the upper left box of the report, the window in Figure 6.9a is presented.
After the reader selects the hyperlink associated with the “Males” class-level heading, the window in Figure 6.9b is presented.
After the reader selects the hyperlink associated with the “Females” class-level heading, the window in Figure 6.9c is presented.
After the reader selects the hyperlink associated with the “Both Genders” summary heading, the window in Figure 6.9d is displayed.
Data Set | LIPIDS |
Report Example | Example 3.3 |
Featured Steps and Statement | PROC FORMAT
PROC TABULATE ODS statement |
Featured Step Statements and Options | ODS statement: ESCAPECHAR= option
PROC FORMAT
Inline formatting ODS STYLE= options that associate hyperlinks with text in the report placed on these PROC TABULATE statements:
|
Output Destination of Example | RTF |
Related Technique | PROC REPORT |
Related Technique Features | PROC REPORT statement ODS option: STYLE(HEADERS)
CALL DEFINE statement ODS option: URL attribute COMPUTE block COMPUTE AFTER block Inline formatting Specifying a heading that spans multiple columns |
Other Examples That Use This Data Set | Examples 2.7, 3.3, 6.4, and 6.8 |
Example 3.3 statistically summarizes the three lipid measurements in the LIPIDS data set. It presents the descriptive statistics for the categories defined by testing period and for those defined by the combination of testing period and gender.
This example produces a report similar to the one produced by the PROC TABULATE step in Example 3.3. It illustrates how you can add hyperlinks to the body of your reports. Hyperlinks can provide your readers with a means to access further information associated with your report. The hyperlinks in this example link to files containing descriptive and detailed information about the data that was summarized.
Four hyperlinks are placed in the body of the report in these locations:
□ | the upper left box of the table |
□ | the class-level heading for males |
□ | the class-level heading for females |
□ | the summary-level heading for both genders |
The URL attribute is added to the style formatting instruction in the $GENDER format definition and to the STYLE option in two places on the TABLE statement in the PROC TABULATE step. The value assigned to a URL attribute is the name of the file that opens when the reader selects the hyperlink.
This example specifies links to three kinds of files: a Microsoft Excel workbook, an HTML file, and a text file. The references to the Microsoft Excel workbook point to specific cells in specific sheets in the workbook.
A hyperlink to a Microsoft Excel workbook can be written in one of two ways:
□ | a hyperlink to the workbook (e.g., url=’c: eportslipids.xls’) |
□ | a hyperlink to a specific worksheet and cell in the workbook (e.g., url=’c: eportslipids.xls#Males!A1’) |
The user-defined format uses ODS inline formatting and relies on the assignment of an ODS escape character before any application of the format. See Example 6.12 for a discussion of inline formatting.
You can also adapt the related technique in Example 3.3 to include hyperlinks to additional information. The following program uses the same PROC REPORT program with the addition of code that assigns hyperlinks to elements of the report and that formats some elements of the report. Figure 6.9e presents the output from this program.
Four hyperlinks are placed in the body of the report in these locations:
□ | the upper left box of the table |
□ | the class-level heading for males |
□ | the class-level heading for females |
□ | the summary line below the table |
This related technique adds a text string above the GENDER and TESTPERIOD columns and associates a hyperlink with the text string.
The program includes a COMPUTE AFTER block that adds a summary line at the end of the report and associates a hyperlink with this summary text.
Instead of associating hyperlinks with the value labels of the $GENDER format as in the PROC TABULATE step in the preceding program, this program uses a CALL DEFINE statement in a COMPUTE block for the variable GENDER. The CALL DEFINE statement can place hyperlinks in cells of your report. The attribute name provided to the CALL DEFINE statement for this purpose is URL.
The same four windows that were displayed by the hyperlinks in the PROC TABULATE step and shown at the beginning of this example are also displayed when their respective hyperlinks are selected from the report produced by PROC REPORT.
The program that produced the output in Figure 6.9e follows.
Do not send results to the LISTING destination. | ods listing close; |
Specify the character that indicates to ODS that what follows the character are style attributes and formatting instructions. Select a character that you know is not part of a character value in your data. | ods escapechar='^'; |
Send subsequent results to the RTF destination and save the results in a file. | ods rtf file='c: eportsexample33c.rtf'; proc format; value $gender 'M'='Males' 'F'='Females'; run; |
Set the background color of the headings. | proc report data=lipids nowindows box style(headers)={background=white}; |
Define a heading that spans the GENDER and TESTPERIOD columns. Associate a hyperlink with the heading. Precede the heading text with a formatting instruction. Start the formatting instruction with the escape character. Indicate that this is a style instruction. Conclude the style instruction with the hyperlink assigned to the URL attribute. | title 'Exercise Program Results'; column ("^S={url='c: eportslipidsdesc.txt'}Exercise and Lipids Study" gender testperiod) chol,(n mean std p25 p50 p75) hdl,(n mean std p25 p50 p75) tri,(n mean std p25 p50 p75); define gender / group format=$gender. left id descending 'Gender'; define testperiod / group left id descending 'Testing Period'; define chol / 'Cholesterol'; define hdl / 'HDL'; define tri / 'Triglycerides'; define n / format=4. 'N'; define mean / format=5.1 'Mean'; define std / format=5.1 'Std Dev'; define p25 / format=5.1 'P25'; define p50 / format=5.1 'P50'; define p75 / format=5.1 'P75'; |
Define a COMPUTE block for the variable GENDER. | compute gender; |
Define a new variable to hold the pathname of the hyperlinked file whose values will be supplied to the CALL DEFINE statement. Specify a different file for each of the two values of GENDER. | if gender='M' then urllink="c: eportslipids.xls#Males!A1"; else if gender='F' then urllink="c: eportslipids.xls#Females!A1"; |
Associate a hyperlink with each class-level heading of GENDER. | call define('gender','url',urllink); endcomp; |
Define a COMPUTE block that executes at the end of the report. | compute after; |
Place a line of text at the end of the report. Associate a hyperlink with this concluding text. | line "^S={url='c: eportslipids.html'}View Data for Both Genders"; endcomp; run; |
Terminate sending output to the RTF destination. | ods rtf close; |
Send subsequent output to the LISTING destination. | ods listing; |
18.227.13.51