SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Drill-Down Graphs in HTML
Defining Values for Link Locations


Now that you've created the variable (PriDrill) to store the HREF addresses, the next step is to supply it with values. These values will determine what pages are displayed when users click the bars of the chart.


Defining link values


Remember that your chart has four bars that track product sales by year. Because each bar shows only total sales for that year, you'll provide more detail by making each bar be a link to a page with another chart:
  • sales95.html
  • sales96.html
  • sales97.html
  • sales98.html.

The bar that represents YEAR=1995 will be a link that loads sales95.html, which will hold a chart of 1995 sales by quarter. The bar for YEAR=1996 will load sales96.html, and so forth.


Assigning Values Conditionally

You'll create the secondary pages and their charts in a moment. For now, just assign their links to the variable PriDrill, basing each value on the value of YEAR. To perform an action based on a condition, use an IF-THEN statement. The IF-THEN statement executes a SAS statement when the condition in the IF clause is true.


General form, IF-THEN statement:
IF expression THEN statement;

where

  • expression is any valid SAS expression.
  • statement is any executable SAS statement.


In this case, your executable SAS statement assigns a text string to PriDrill. Begin each string with HREF= to indicate a link address, then enclose the address in quotation marks. HTML filenames can end in either .html or .htm, and the HREF location can be any reference that is valid in HTML.

     data work.saletrnd;
        set finance.prdsal2;
        format actual dollar10.0;
        length PriDrill $ 40;
        if year=1995 then pridrill='HREF="sales95.html"';
        if year=1996 then pridrill='HREF="sales96.html"';
        if year=1997 then pridrill='HREF="sales97.html"';
        if year=1998 then pridrill='HREF="sales98.html"';
     run;

Note: HREF addresses can lead to anchors within HTML pages. To specify an anchor, add a pound sign (#) and the anchor name to the HREF address string.

For example, HREF="sales98.html#office" specifies the anchor named office within sales98.html. To have links lead to anchors on the same page as your chart, omit the HTML page name and use only the pound sign and anchor name: HREF="#office".


  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement