SAS Institute. The Power to Know

FOCUS AREAS

508 GRAPHS in SAS, Version 8

GACCESSIBLE Macro

Macro Usage

Macro Reference

Macro Code

EXAMPLES

One Graph in Output

Multiple Graphs

508 INFO


ODS Support

SAS Accessibility Statement

SAS, Version 8: 508 Graphs

The GACCESSIBLE Macro: One Graph in Output

To generate accessibility information with the GACCESSIBLE macro, you use ODS to generate the graph in an output HTML file. Next, you close the HTML file so that the GACCESSIBLE macro can get write access to it, and you then invoke the macro. The SAS program on this page invokes the macro to generate accessibility information for 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 link in the graph's lower left corner to see the accessibility information that is associated with the graph.


SAS Output
VBAR chart of Age

SAS Program


/*----------------------------------------------------------
 * NAME:     Accessible Bar Chart
 * 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.
 * REQUIRES: BASE SAS and SAS/GRAPH Software (Version 8.2 or later).
 *           You must first submit the GACCESSIBLE macro
 *           source code in your SAS session.
 * 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.onegraph.html";

/* Create summary data for the accessibility information. 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, axis options, and a pattern for the 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 a 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='barchart';
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. FILENAME must
 * use MOD and ODS HTML must use NO_TOP_MATTER.
 *------------------------------------------------------------*/
filename out "&path.onegraph.html" mod;
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;

/* Release the fileref and reopen the listing destination. 
 *------------------------------------------------------------*/
filename out;
ods listing;