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

Support

Sample 26112: Create a sample sales management dashboard

DetailsCodeOutputDownloadsAboutRate It

This sample uses the GCHART and GPLOT procedures in conjunction with the Annotate facility in the SAS/GRAPH software to create a variety of indicators, and then uses the GREPLAY procedure to arrange the indicators into a dashboard.

Note: This dashboard is described on p. 199 of Information Dashboard Design (Few, Stephen. 2006. Sebastopol, CA. O'Reilly Media, Inc.).

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

This sample creates a full-blown dashboard for a telesales organization. It creates the following custom charts:

  • PLOT1: Overall Rep Performance
  • PLOT2: Overall Rep Performance sparkline data
  • PLOT3: Rep Utilization
  • PLOT4: Rep Utilization sparkline data
  • PLOT5: Volume - call count
  • PLOT6: Volume - order count
  • PLOT7: Individual Rep Performance

It then uses the GREPLAY procedure with a custom layout template to place the charts onto a telesales dashboard. Here is the layout of the custom template:

layout of the telesales dashboard template

About the Data Sets

This sample creates the following SAS data sets that correspond to the plots:

  • DATA1
  • DATA2
  • DATA3
  • DATA4
  • DATA4_TABLE
  • DATA5
  • DATA6
  • DATA7

You can see the definition for these data sets near the top of the SAS program for this sample. The numbering for the plots and SAS data sets corresponds to the location of the charts in the dashboard layout.

Here are the variables that you must use in each of the data sets:

Data Set Name Variable Name Description
DATA1
CATEGORY specifies the name of the data category. Can be Hold Time, Call Duration, or Abandonments.
PERCENT_OF_TARGET specifies the percent of the target. Can be 0 to 2.5 (0 to 250%).
ACTUAL_VALUE specifies the actual numeric value.
DATA2 CATEGORY specifies the category. Can be 1, 2, or 3. 1 shows at the bottom.
CATEGORY_NAME specifies the category name. It is set based on the value of CATEGORY as follows : 1 = Hold Time, 2 = Call Duration, and 3 = Abandonments.
TIMESTAMP specifies a numeric timestamp.
PERCENT_OF_TARGET specifies the percent of the target as 0-n%.
DATA3 BARNUM specifies the bar number. Since only bar exists, always use 1.
SEGMENT specifies the three ranges. Can be 1, 2, or 3.
VALUE specifies the percent utilization. Can be 0.75 to 1.00 (75% to 100%).
DATA4 CATEGORY specifies the category. Can be 1 or 2.
CATEGORY_NAME specifies the category name. It is set based on the value of CATEGORY as follows: 1 = Order Count and 2 = Call Count.
TIMESTAMP specifies a timestamp as 1,2,...n.
PERCENT_OF_TARGET specifies the percentage of the target value as 0-n%.
DATA4_TABLE CAT_NAME specifies the category name. Can be Call Count or Order Count.
CATEGORY specifies the category. Can be 1 or 2.
THIS_HOUR specifies the count for the current hour.
TODAY specifies the count for the current day.
THIS_MONTH specifies the count for the current month.
DATA5 CALLS_PER_REP specifies the calls per representative as a character string range. Can be: '0-4','5-9','10-14','15-19','20-24','25-29', or '30-34'.
REPS specifies the number of representatives in this bar.
DATA6 ORDERS_PER_REP specifies the orders per representative as a character string range. Can be: '0-3','4-7','8-11','12-15','16-19','20-23', or '24-27'.
REPS specifies the number of representatives in this bar.
DATA7 TEXT specifies the representative's name preceded by a '.' if the representative is online or an 'X' if the representative is offline.
NAME specifies the representative's name without the '.' or 'X' prefix.
OFFLINE specifies whether the representative is online or offline as follows: '.' = online, 'X' = offline.
ORDER_PER_HOUR specifies the number of orders per hour for this representative.
CALLS_PER_HOUR specifies the number of calls per hour for this representative.
CALL_DURATIONL specifies the minimum call duration for the group.
CALL_DURATION1 specifies the group call duration for the first quartile.
CALL_DURATIONM specifies the median call duration for the group.
CALL_DURATION3 specifies the group call duration for the third quartile.
CALL_DURATIONH specifies the maximum call duration for the group.
SET_ORDER

specifies how the bars are to be sorted. It is computed as follows:
Orders_Per_Hour+(Calls_Per_Hour/100)
The smallest values are displayed at the top of the list for attention.

You can change the data in the SAS program and rerun it to see how the changes affect the dashboard. You can also replace the hard coded data with a query that pulls similar data from your live databases to plot on the dashboard. However, the data from your databases must be similar and you must use the same variable names.

How the Plots are Created

Here are some notes on how this sample generates the plots for the dashboard:

PLOT1

To generate PLOT1, the GCHART procedure is used to create a horizontal bar chart. The bars that need attention are annotated with orange and red dots to the left of the bars. The bars are also annotated with the actual value (data1_anno) to the right of the bars. Custom titles are placed along the top of the chart using the Annotate function='label'. Annotated areas are created behind the bar chart by specifying large annotated function='bar' areas of specific colors behind the chart (data1_anno2).

When the GCHART procedure is run, ref=1 is used to put a reference line at 100%, and the HTML= option is used to identify the variable that contains the HTML chart tip and drill-down information for the individual bars. The TITLE1, TITLE2, and TITLE3 statements are used to add white space around the chart in order to reserve room for the custom annotation. Notice that the midpoint axis is hard coded so that the order of the bars corresponds to the order of the sparklines in PLOT2. It is important to ensure that the order of the bar chart and sparklines match, since these charts complement one another.

PLOT2

To generate the Overall Rep Performance sparklines, the GPLOT procedure is used to overlay three lines on the same plot. To make the lines appear one above the other, an offset is added successively to the Y coordinate of each line. Axis statements are used to suppress the normal GPLOT axis. For the sparkline, a reference line is added on the vertical axis at the 100% target value to allow the viewer to see how the actual value compares to the target value over time.

Since the sparklines do not have markers, chart tips and drill-down links cannot be added to the the sparklines. To provide drill-down functionality, an invisible annotated bar is added around the entire graph area. The viewer can click on the bar to drill down to the detailed data.

PLOT3

To generate PLOT3, the GCHART procedure is used to generate a bar chart. The SUBGROUP option is used to shade the segments of the bar to correspond to the good, excessive, and critical ranges. A red or orange dot is annotated beside the bar chart if it needs attention (excessive or critical). The annotated dot is created by using the W character of the SAS/GRAPH marker software font and annotating that text using the label function.

Rather than the bar representing the actual value, in this case, the bar represents the good, excessive, and critical ranges. A line is annotated on the bar to represent the actual value. The Annotate MOVE and DRAW functions are used to create the annotated line. Annotated text labels and an annotated line are used to create the equation to the right of the bar chart. The Annotate MOVE and DRAW functions are used to draw the annotated line. An angled title with blank text and a large height is used to create the white space to the right of the bar chart. The GCHART HTML= option is used to create a drill-down link on the bar itself.

PLOT4

To generate PLOT4, the GCHART procedure is used to create sparklines that are similar to those that were created in PLOT2. Annotated text is then used to place the table to the left. The two rows in the table correspond to the two sparklines; therefore, the Annotate facility uses the data coordinate system (YSYS='2') and the same 'y_position' variable as the sparklines. Blank, angled titles are used to create white space around the plot to reserve space for annotations. A large amount of white space is reserved on the left side of the plot to reserve space for the annotated table.

As was done in PLOT2, because the sparklines have no markers, to create drill-down functionality, an invisible annotated bar is added around the entire graph area. The viewer can click on the bar to drill down to the detailed data.

PLOT5 and PLOT6

To create PLOT5 and PLOT6, the GCHART procedure is used to create a vertical bar chart. Instead of letting the GCHART procedure group the bars, a character string in the data is used to group the data. Normally, the GCHART procedure arranges these character strings in alphabetical order. However, in this case, an AXIS statement is used to specify the desired order of the groups as follows:

order=('0-4' '5-9' '10-14' '15-19' '20-24' '25-29' '30-34')

The GCHART HTML= option is used to identify the variable that contains the HTML HREF tags for the drill-down and chart tip information.

PLOT7

To generate PLOT7, the GCHART procedure is used to draw the horizontal axes and to arrange the bars and boxes in the desired (ascending) order of Orders_Per_Hour+(Calls_Per_Hour/100), from top to bottom. Annotate is then used to draw the box plots. Here are the variables that are used to control the geometry of the custom annotated box plots:

CALL_DURATIONL (group minimum)
CALL_DURATION1 (group first-quartile)
CALL_DURATIONM (group median)
CALL_DURATION3 (group third-quartile)
CALL_DURATIONH (group maximum)

You can use the BOXPLOT procedure to calculate these variables from your raw data and then input them into this custom dashboard code.

The Annotate HTML variable is used to add drill-down links and chart tips to the the custom annotated box/bars. The user can click on them to drill down to the detailed data. On the box/bar midpoint axis, an AXIS statement is used to suppress the default values. Custom text labels for the name, orders, and calls are then annotated on the axis. The HTML variable in the Annotate data set is used to add a link on the name labels so that a viewer can click on a name to send a message to that representative.

How the Dashboard Titles and Annotations are Created

In the dashboard in this sample, most of the overall title information is located at the bottom edge. The Annotate LABEL function is used to create these titles. Since the title slide is replayed into area 0 in the custom GREPLAY template, annotations can be added anywhere on the dashboard. The Annotate MOVE and DRAW functions are used to draw dividing lines to separate and group the pieces of the dashboard. Although the GREPLAY procedure can draw outlines around each individual GREPLAY area, Annotate provides more flexibility in grouping items visually. For example, notice that PLOT4, PLOT5, and PLOT6 are grouped by a simple outline that is drawn around all three of them. This cannot be done using the GREPLAY procedure.

How the Dashboard is Created

When the plots are generated, the output is stored in GRSEGs. The GREPLAY procedure is then used to assemble the plots onto a single page using a custom GREPLAY template. The custom GREPLAY template is defined by specifying four X and Y coordinates for the rectangular area that will hold each graph. The units of the X and Y coordinates are the percentage of the total length of the axis where the coordinate is located, with 0,0 being at the bottom-left corner. Each rectangular area is assigned an ID number. Here are the coordinates that place the Rep Utilization chart in the middle-left of the dashboard in area 4:

   4/llx =  0  lly =38
     ulx =  0  uly =53
     urx = 60  ury =53
     lrx = 60  lry =38

where LLX is the lower-left X coordinate, LLY is the lower-left Y coordinate, and so on.

The GREPLAY procedure allows you to overlap the rectangular areas. Area 0 is defined as covering the entire dashboard. The GSLIDE procedure is used to place the title text near the top-right corner, and the Annotate facility is used to create a custom legend. Here are the coordinates:

   0/llx = 0   lly =  0
     ulx = 0   uly =100
     urx =100  ury =100
     lrx =100  lry =  0

Here is the GREPLAY procedure TREPLAY (template replay) action statement that draws the appropriate charts into the desired areas
of the custom GREPLAY template:

   treplay
    1:plot1 2:plot2
    3:plot3              7:plot7
    4:plot4
    5:plot5 6:plot6
            0:titles

Note: For convenience and code readability, spacing is used in the TREPLAY action statement to make the layout correspond to the actual location of the charts in relation to one another.

Notice that the PLOT7 GRSEG is played into area 7.

For each chart on the dashboard, this sample adds a drill-down link to a detailed table of the data for the chart. To keep this sample self-contained, the drill-down tables are placed on the same output page just below the dashboard, and each table is identified using an HTML anchor as follows:

ods html anchor="&anchor_name";

However, in your case, these drill-down links would likely be to separate detail tables or charts on a separate page.

In this sample, the anchor names are created when the bar charts are created as follows:

   htmlvar=
   'title='||
    quote(
    'Quarter: '|| trim(left(quarter)) ||'0D'x||
    'Target: '|| trim(left(put(target,&value_format))) ||'0D'x||
    'Actual: '|| trim(left(put(actual,&value_format))) ||'0D'x||
    'Actual as Percent of Target: '|| trim(left(put(percent_of_target,percent6.0)))
     ) || ' '||
   'href="#'||trim(left("&grseg_name"))||'"';

To keep the naming simple and consistent, the GRSEG names are used as the anchor names. While you are viewing the dashboard, if you mouse over each bar, the data value for the bar is displayed in the HTML chart tip. If you click a bar, your browser scrolls down to the HTML anchor to show you the table of the data for the bar.




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.