Example 6.9. Placing Hyperlinks in a Report

Goal

Add hyperlinks to elements of a report so that the reader can access additional information related to the report by selecting a hyperlink.

Report

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.

Figure 6.9a. The Window Displayed after Selecting the Hyperlink in the Upper Left Box of the Report


After the reader selects the hyperlink associated with the “Males” class-level heading, the window in Figure 6.9b is presented.

Figure 6.9b. The Window Displayed after Selecting the Hyperlink Associated with the “Males” Class-Level Heading


After the reader selects the hyperlink associated with the “Females” class-level heading, the window in Figure 6.9c is presented.

Figure 6.9c. The Window Displayed after Selecting the Hyperlink Associated with the “Females” Class Level Heading


After the reader selects the hyperlink associated with the “Both Genders” summary heading, the window in Figure 6.9d is displayed.

Figure 6.9d. The Window Displayed after Selecting the Hyperlink Associated with the “Both Genders” Summary Heading


Example Features

Data SetLIPIDS
Report ExampleExample 3.3
Featured Steps and StatementPROC FORMAT

PROC TABULATE

ODS statement
Featured Step Statements and OptionsODS statement: ESCAPECHAR= option

PROC FORMAT

Assigning style options that associate hyperlinks to value labels

Inline formatting

ODS STYLE= options that associate hyperlinks with text in the report placed on these PROC TABULATE statements:

TABLE

BOX= option on the TABLE statement

Output Destination of ExampleRTF
Related TechniquePROC REPORT
Related Technique FeaturesPROC 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 SetExamples 2.7, 3.3, 6.4, and 6.8

Example Overview

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.

Program

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';

Associate a hyperlink with each value label. Precede the value label 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.
proc format;
  value $gender 'M'=
       "^S={url='c:
eportslipids.xls#Males!A1'
}Males"
                'F'=
  "^S={url='c:
eportslipids.xls#Females!A1'
}Females";

 
run;
proc tabulate data=lipids;
  title 'Exercise Program Results';
  class gender testperiod / descending
                            style={background=white};
    classlev gender testperiod /
                  style={background=white};
    var chol hdl tri / style={background=white};
    table (gender='Gender'

Set the background color of the cells containing the headings for the class variables, the headings for the analysis variables, and the cells containing the class level values.
Associate a hyperlink with the descriptive text assigned to the ALL keyword.
all="^S={url='c:
eportslipids.html'}Both Genders")*


         testperiod='Testing Period',
         all='Lipid Profile'*
         (chol='Cholesterol' hdl='HDL'
         tri='Triglycerides')*
         (n*f=3.
         (mean std='Std Dev' p25 p50 p75)*f=5.1)
         / box={label='Exercise and Lipids Study'
          style={url='c:
eportslipidsdesc.txt'
                background=white}}

Associate a hyperlink with the descriptive text placed in the upper left corner of the report and set the background color of the box.
         


         nocontinued;
    keyword all n mean std p25 p50 p75
            / style={background=white};

Set the background color of the cells containing the headings for the keywords.

    format gender $gender.;
run;

Terminate sending output to the RTF destination.
ods rtf close;

Send subsequent output to the LISTING destination.
ods listing;


Related Technique

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.

Figure 6.9e. Output from the PROC REPORT Related Technique that Includes Hyperlinks


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;


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.13.51