To use the GACCESSIBLE macro to generate accessibility information for multiple graphs in the same output file, you invoke the macro separately for each graph. The SAS program on this page invokes the macro twice to generate accessibility information for two graphs: a plot and a bar chart. The example shows you how to
You must create the macro in your SAS session before you can submit the code that is shown below.
The following figure shows the program output. Click the links in either graph's lower left corner to see the accessibility information that is associated with that graph.
|
|
/*----------------------------------------------------------
* NAME: Accessible Graphs
* PURPOSE: This program illustrates a web accessible
* solution using ODS and SAS/GRAPH to meet the
* requirements of Section 508 of the Federal
* Rehabilitation Act.
* You must first submit the GACCESSIBLE macro
* source code in your SAS session.
* REQUIRES: BASE SAS and SAS/GRAPH Software (Version 8.2 or later)
* SUPPORT : Business Intelligence Usability
*------------------------------------------------------------*/
/* This is the only line that you must change in the
* program. Specify a path for your HTML file. Do not use
* quotation marks around the path.
*------------------------------------------------------------*/
%let path=specify-a-path-for-the-HTML-file;
/* To coordinate output with the GACCESSIBLE macro, the ODS HTML
* statement's FILE= (alias BODY=) option must use a fileref,
* which is defined on a FILENAME statement.
*------------------------------------------------------------*/
filename out "&path.multigraph.html";
/* Create summary data for the graphs. For the bar chart,
* the GACCESSIBLE macro's DSN= parameter will reference the
* output data from this procedure run. Macro parameter VARS=
* will reference data set variables AGE and HEIGHT.
*------------------------------------------------------------*/
proc means data=sashelp.class nway noprint;
format height 6.2;
label height="Average Height";
var height;
class age;
output out=stats mean=Height;
run;
/* Assign graphics options and close the listing destination.
*------------------------------------------------------------*/
goptions reset=all device=gif
ftext="Arial"
xpixels= 480
ypixels= 360
gunit=pct
;
ods listing close;
/* Create a style that modifies the default style used by ODS.
* Change the page background color (bgA) to white. Retain
* other color definitions. Though the GIF device driver does
* not derive graph colors from the style, Java-based or
* ActiveX-based device drivers can use it.
*------------------------------------------------------------*/
proc template;
define style whiteBackground;
parent=styles.default;
replace color_list /
'fgB2' = cx0066AA
'fgB1' = cx004488
'fgA4' = cxAAFFAA
'bgA4' = cxD6D3D6
'bgA3' = cxE7E3E7
'fgA2' = cx000000
'bgA2' = cx639ACE
'fgA1' = cx000000
'bgA1' = cxffffff
'fgA' = cx0000FF
'bgA' = cxffffff;
end;run;
/* The initial HTML output must have NO_BOTTOM_MATTER. The
* GPATH= option is used to direct graph image files (GIF
* files in this example) to the same location used for the
* output HTML file. The STYLE= option is used so ODS will
* derive the page background color from the whiteBackground
* style. The GIF device driver ignores the style, but
* Java-based or ActiveX-based drivers will use it if you
* change the code to use one of those drivers.
*------------------------------------------------------------*/
ods html gpath="&path"
file=out (no_bottom_matter)
style=whiteBackground;
/* Assign a title and axis options for the plot.
*------------------------------------------------------------*/
title1 h=6 "Plot of Class Data";
axis1 label=(h=4.5)
value=(h=4)
major=(color=cxC2C7D2)
order=(54 to 72 by 3)
minor=none;
axis2 label=(h=4.5)
value=(h= 4)
major=(color=cxC2C7D2)
minor=none;
/* Assign interpolation: marker style, color, size: line color.
/*-----------------------------------------------------*/
symbol1 interpol=join font=marker value=U c=cx94B7DA h=2;
/* Create the plot.
/*-----------------------------------------------------*/
proc gplot data=stats;
plot height*age/
vaxis=axis1
haxis=axis2
autovref
cautovref=cxC2C7D2
noframe
name='line'
description="Line Chart of Class Data";
run;quit;
/* Close the HTML destination so the GACCESSIBLE macro
* can get write access to the output HTML file.
*------------------------------------------------------------*/
ods html close;
/* Generate an accessibility description for the plot. The
* apostrophe in the text requires a macro quoting function.
*------------------------------------------------------------*/
%gaccessible(fileref=out,
desc=This is a plot of children%str(%')s height by age.)
/* Redefine the fileref so new ODS content is appended to the
* file and does not replace existing content. Do this by
* using the MOD option on the FILENAME statement.
*------------------------------------------------------------*/
filename out "&path.multigraph.html" mod;
/* To write to the existing output file, ODS HTML needs
* both the NO_TOP_MATTER and NO_BOTTOM_MATTER suboptions.
*------------------------------------------------------------*/
ods html gpath="&path" body=out
(no_top_matter no_bottom_matter);
/* Assign a new title, and axis and pattern options for the
* bar chart.
*------------------------------------------------------------*/
title1 h=6 "Bar Chart of Class Data";
axis1 label=(h=4.5) value=(h=4) major=(color=cxC2C7D2)
order=(0 to 75 by 15) minor=none;
axis2 label=(h=4.5 'Age') value=(h= 4) minor=none;
pattern1 c=cx94B7DA;
/* Create the bar chart.
*------------------------------------------------------------*/
proc gchart data=stats;
vbar age/
sumvar=height type=mean discrete
raxis=axis1 maxis=axis2
autoref cautoref=cxC2C7D2 clipref
noframe
width=15 coutline=cx003399
name='bar';
run;quit;
/* Close the HTML destination so the GACCESSIBLE macro
* can get write access to the output HTML file.
*------------------------------------------------------------*/
ods html close;
/* This macro writes a description and the summary data from
* the PROC MEANS procedure above. The macro automatically
* creates a link to associate this information with the chart.
*------------------------------------------------------------*/
%gaccessible(fileref=out,
dsn=stats, vars=age height,
desc=This is a bar chart of age summarized by height.);
/* Write HTML closing tags to the output file. ODS HTML
* must use NO_TOP_MATTER. FILENAME is not needed this time
* because the fileref is already set for modifying the file.
*------------------------------------------------------------*/
ods html body=out (no_top_matter);
/* Close the output file and release the fileref.
*------------------------------------------------------------*/
ods html close;
filename out;
/* Clear titles, footnotes, and goptions.
*------------------------------------------------------------*/
title;
footnote;
goptions reset=all;
/* Reopen the listing destination.
*------------------------------------------------------------*/
ods listing;