Click here to see the SAS code.
Click here to see the example.

As computers have become more capable and flexible, more software manufacturers are trying to ensure that their software can be used by people with various handicaps. This is often referred to as 'accessibility'. One area of accessibility focuses around enhancing the software interface so that users can interact with the GUI using simple keyboard strokes rather than having to manipulate a mouse. Another area is the encoding of text in the output in such a way that the computer with screen-reading software (such as JAWS or Window-Eyes) can read the text aloud to a blind, or vision-impaired, user. This paper focuses on the second area.

Many of our competitors don't allow you to have machine-readable text in their graphics, much less to control what the text says. Sas/graph not only supports several kinds of machine-readable text, but it also allows you to control that text to say *exactly* what you want. With more governments and companies starting to care about this, and adding 'accessibility' to their software selection criteria (such as the US government's Section 508 of the Rehabilitation Act), we can use this as a strong selling point for sas software! :-)

Here is an example of a graph that demonstrates several ways to encode machine-readable text in sas graphics, and below that I describe in detail how to use each of the techniques that are demonstrated in the graph. When you view this graph, you can hover your mouse over the various areas to see the html title text, or if you have a browser tool that supports machine-reading of the text, you can actually use that to 'see' (ie, hear) the graph like a blind person would ...

By default, when using ods html and device=gif, sas/graph uses 'gtitles' (that is, the titles are 'drawn' as part of the graph), and would not be readable by the text-reading software. But, you can use the ods 'nogtitle' option to cause the titles to be brought outside of the graph, and coded into the html as an html '< title >' which the text readers can easily read. (Special note: prior to v9.1 sas the nogtitle titles were encoded into the html as html tables rather than html titles). Here is an example of an ods html statement that uses the nogtitle option...

 ODS HTML path=odsout body="somename.htm" nogtitle;

Footnotes work similarly to titles, except you use the ods 'nogfootnote' option to control the footnotes.

What I call 'graphical elements' are perhaps the most important part of the graph, and are the pieces that represent the data values. In a bar chart the bars are the graphical elements. In a pie chart, the pie slices. In a map, the areas (such as states in the US map, or countries in the europe map). In a scatter or line plot, the markers.

Most of the sas/graph procs support the 'html=' option, and this allows you to encode html 'title=' information (aka, "html title text") such that you can specify text for each of the graphical elements. You can either hard-code the title text, or dynamically generate it in a data step so that it is generated from (or based on) the data values when you run the sas code. Below is an example showing how you might piece info from several variables together to use as the title text. This might look a little complicated, since several pieces of text are being interwoven with several data values (and using formats and functions along the way), but don't let that scare you away! More often you will probably only be showing the value of 1 variable in the title text, and that will be much simpler and shorter to code than this example:

data work.a; set work.a;
 length  myhtmlvar $300;
 myhtmlvar=
 'title='|| quote(
    ' Age '||trim(left(put(agegroup,agefmt.)))||
    ' = '|| trim(left(put(pct,percent6.0)))||
    ' of '|| trim(left(fipnamel(stfips(state))))||' population '||
    ' ')||' ';
run;

This is a little-known feature of sas, and is *very* useful! In addition to allowing the screen-reading programs to read the information to the user, it also allows an easy way to encode extra info into the chart, without cluttering up the graphics area with text labels.

Perhaps even less well-known than including title text in the graphical elements of the chart, is the ability to include title text with the annotation that is overlaid on a chart! Html= support for annotated labels, symbols, bars, and polygons has been available since v7.01, and in v9 support was added for title text in annotated images, pies, etc.

The syntax is the same as the syntax of the html= variable used in the sas graph procs, but in the annotate dataset the variable *must* be named 'html'. The following sample code shows how I annotated a gif image onto my chart, and associated html title text with that image:

data work.logoanno;
   length  function style $ 8 html $ 300;
   xsys='3'; ysys='3'; hsys='3'; when='a';
   function='move'; x=65; y=80; output;
   function='image'; style='fit'; x=100; y=95; imgpath='acsonly.gif';
   html='title="American Community Survey logo" href="http://www.census.gov/acs/www/index.html"';
   output;
run;

With images on the web (such as a gif image of a sas/graph), it is common practive to have an 'title' description of the entire graph. SAS/GRAPH supports this with the des= option. Using this option, you can hard-code a *short* bit of descriptive text to describe the entire graph. Starting in v9.1, sas/graph produces a default title description of the charts (a generic one, just using the names of the variables being plotted) -- you can override this default description by specifying des='{your text}', or you can eliminate it by using des=''. In this example, I use the following des=

Another place you might put a piece of short descriptive text to describe the entire chart is as the label for the bookmark. SAS allows you to control that using the ods 'title=' option. The text-readers have access to this text, and it is also useful in that it provides a textual description for your browser when you bookmark the graph. You can place the ods (title= ) option right after the body=, as shown in the example below:

 ODS HTML path=odsout body="somename.htm"
 (title="Bar Chart of Age Distribution of people in NC")
 nogtitle;

A technique that has recently come into vogue is to put something that is often called a 'dLink' (descriptive link) in the graph, which contains a long textual description (longer than the image's title= or bookmark label) of what is going on in the graph. This link is typically placed in an inconspicuous location so it doesn't distract the people who don't need it, and is sometimes even made the same color as the background, so that only the text-reading programs notice it.

Currently there is no way to automatically generate 'official' dLink text in sas, but you might wish to point the dLink to some textual sas output from a statistical proc, or maybe some output from proc tabulate or proc print. Or, as in this example, you could point the dLink to a long textual description that someone has written (such as a written report or paper). Once you have determined what the link will go to, you can implement the link itself using an annotated text label, or you could use a footnote with text 'dLink' and a link to the textual description. This example uses the latter technique:

 footnote2 justify=r
 link="http://www.census.gov/acs/www/Products/Profiles/Single/2002/ACS/Narrative/040/NP04000US37.htm"
 "dLink";
Back to Samples Index