Service Packs for the SAS9 Platform." />
SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 26120: Create a bar chart indicator for a dashboard using a stored process

DetailsCodeOutputDownloadsAboutRate It

This sample uses the GCHART procedure in conjunction with the Annotate facility in the SAS/GRAPH software to create a single bar chart indicator for use in a dashboard. This version is intended to run as a SAS stored process. For a sample of a complete dashboard, see Create a dashboard with multiple bar chart indicators using a stored process.

This sample contains the macro %DO_CHART, which draws a bar chart that shows one value as the bar and another value as a triangular marker. In this sample, the bar height is sales and the triangular marker is the sales target. The bar and marker colors are based on the difference between the actual sales and the target. You can reuse the %DO_CHART macro to create a similar chart of your own. To use the macro, create a SAS data set that contains four observations of the following variables:

TITLE_TEXT
specifies a title for the graph.
QUARTER
specifies the quarter as 'Q1', 'Q2', 'Q', or 'Q4'.
ACTUAL
specifies the numeric height of the bar.
TARGET
specifies the numeric target (triangle) value.
VALUE_FORMAT
specifies the format that is to be applied to the numeric axis.
POOR_PCT
specifies the percentage of the target under which the sales value is to be considered poor.
GOOD_PCT
specifies the percentage of the target over which the sales value is to be considered good.
Y_MAX
specifies the maximum value for the Y axis.
Y_BY
specifies the maximum value for the X axis.

Here is an example of a data set for the %DO_CHART macro:

   data data1;
   length value_format $15;
   input title_text $ 1-20 quarter $ 22-23 actual target value_format poor_pct good_pct y_max y_by;
   datalines;
   Market Share         Q1   .23    .24   percentn6.0   .65 .90    .30    .10
   Market Share         Q2   .20    .25   percentn6.0   .65 .90    .30    .10
   Market Share         Q3   .19    .26   percentn6.0   .65 .90    .30    .10
   Market Share         Q4   .17    .27   percentn6.0   .65 .90    .30    .10
   ;

To draw your chart, call the %DO_CHART macro and pass to it as macro parameters the name of your SAS data set and the name of the GRSEG in which the chart is to be stored. Here is an example:

%do_chart(data1,market1);

The %DO_CHART macro takes your data values and plots them as a bar chart. It colors the bars based on their performance and annotates a marker that shows what the target value is in relation to the actual (bar) value. It then stores the chart in GRSEG MARKET1.

For additional information about creating dashboard applications with SAS/GRAPH software, see SAS/GRAPH Dashboard Samples.




These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.