«Paper GH-17 Using SAS® to Create Custom Healthcare Graphics Barbara B. Okerson, WellPoint, Richmond, VA ABSTRACT SAS® graphics products can be used ...»
Using SAS® to Create Custom Healthcare Graphics
Barbara B. Okerson, WellPoint, Richmond, VA
SAS® graphics products can be used to create and deliver high-impact visuals, both as presentation-ready graphics
and as data exploration displays. Using these graphics, users can explore, examine, and present data in an
understandable manner while distributing their findings in a variety of formats to decision makers who can gain a quick, visual understanding of critical issues. Although SAS provides many ready-to-use graphics and graphic formats through SAS/GRAPH software and Output Delivery System (ODS) graphics, sometimes other graphics displays are needed. SAS provides the tools to create almost any desired graphic. This paper shows how SAS can be used to create graphics that are not directly available. Examples are from the healthcare industry.
Results included in this paper were created with SAS 9.1.3 or SAS 9.2 on a Windows XP platform, using Base SAS, SAS/STAT software, and SAS/GRAPH. SAS 9.1 or later is required for ODS graphics extensions.
The sets of available and customizable graphics included within SAS products cannot possibly represent all graphics that might be used to display data and results. Rather than just creating customizable versions and enhancements of these provided graphics, the focus of this paper is using these graphics as a starting point to create new graphics.
Other papers have discussed the creation of custom graphics with SAS. These have emphasized the use of the graphics primitives, Graph Template Language, SG procedures (e.g. SGPLOT, SGPANEL, SGSCATTER), or modifying style templates. The custom graphics in this paper use the SAS procedures in SAS/GRAPH as a base and use them in ways perhaps not intended, or at least not documented, to create graphics that are currently not part of
the SAS graphics library. Custom graphics that are created and included as part of this paper are:
Data sets used in this paper are either publicly available or are test data sets developed for the purpose of data modeling and technique demonstration and are not intended to represent the statistics of an actual population or account. The graphic techniques illustrated in this paper have been used in data presentations; in some cases they have been updated and/or enhanced for this paper. Partial SAS code is included in this paper; the selected code illustrates the techniques used to define the graphics. Complete code for all included graphics is available upon request.
EXAMPLE 1 – HISTORICAL TIMELINESOne of the most convenient ways to display a progression of events is with a timeline. This type of timeline is often referred to as a historical timeline and can be used to identify dates relating to any process or event. Historical timelines differ from the traditional data timelines – those that are used in longitudinal analysis as a means to show data change over time. For historical timelines, each time period represents an event time. Two examples of historic timelines are presented in this paper. In the first example, a historic style timeline is created that tracks event planning for a training session. The second example incorporates images into a more traditional historical timeline of medical history.
EXAMPLE 1a – EVENT TIMELINE In the first timeline example, the X-Y axis is created with SAS/GRAPH Proc GPLOT, with the needle interpolation option used to mark the event points on the X-axis. The points are labeled with a SAS annotate data set. This example represents the basics only. To further enhance the usefulness of this type of timeline, different types of events can be identified by color, and a hierarchy of event importance can be created through font size.
EXAMPLE 1b – HEALTHCARE TIMELINEThis timeline uses pictures as symbols along the timeline as illustrations of the event being depicted. To create this graphic, the normal plot axes, values and symbols are suppressed. The images are matched to the data points in an annotate dataset using the image value of the annotate function variable. The bottom axis label represents the formatted value of the timeperiod variable. When using images, the most important change from using symbols or fonts is that it is necessary to create space for the image. In this example, the space is created by expanding the axes and by adding to the x and y variables after reading in the images.
/*Set Symbols and Axes*/ symbol value=none;
axis1 split='/' label=none minor=none major=none style=0 order=(0 to 5 by 1);
axis2 label=none minor=none major=none order=(0 to 4 by 1) value=none style=0;
EXAMPLE TWO: PROJECT TIMELINESProject management requires the planning, organizing, securing and managing of people and resources that are necessary for successful completion of specific project goals and objectives within the desire timeframe. Project timelines are used to identify and manage all the time and resources needed for project completion. The two most important uses for project timelines are to: 1) explain your project to strangers, and 2) organize your project for you.
SAS software system provides all the tools for project timelines that meet these two needs, by allowing the display on a single page. SAS supports time scheduling and display, through both traditional and specialty products. While many external specialty software products also exist for project management. SAS provides a solution that is robust enough that the actual format of the timeline is up to the user. Two examples follow.
EXAMPLE 2a– TASK TIME SCHEDULE In this example, a time schedule is created for a task within a project. Areas of responsibility are color-coded. This type of schedule is particularly useful because it provides, at a glance, the same information as well-known project planning software. The display is limited to the most necessary factors and provides the time schedule in an easy-toread, scalable format.
/* Set Titles Symbols and Axes*/ title1 h=4 c=black "Quality Improvement Report Timeline";
axis1 label=none major=none minor=none style=0 ;
axis2 label=none major=none minor=none style=0 order="20Feb10"d to "16Mar10"d
axis3 label = none value=(j=l %longtasks) major=none minor=none style=0 ;
/*Plot the Timeline*/ proc gplot annotate=anno;
plot nobs*end/ vaxis=axis1 haxis=axis2 lhref=33 href="01MAR10"d "12MAR10"d vreverse;
plot2 nobs*end/vaxis=axis3 haxis=axis2 vreverse;
format nobs order.;
footnote2 box=1 f=marker c=red h=1.5 'U' f='Arial' c=black h=1.5 ' QI ' f=marker c=gray h=1.5 'U' f='Arial' c=black h=1.5 ' Analytic ' f=marker c=blue h=1.5 'U' f='Arial' c=black h=1.5 ' Other ';
EXAMPLE 2b – PROJECT PROPOSAL TIMELINEThis example provides a one-page activity proposal for a consulting contract. Categories and activities within categories are displayed on a timeline, with the number of days for each activity also displayed. Like the previous timeline, the code, once developed, can serve as a template for future proposals. Although the graphic as displayed shows all categories and subcategories, the code allows for alternate display of major categories only. Additional color-coding can be added to identify areas of responsibility. Proposal section numbers can also be added as left axis values if required.
EXAMPLE 2b SELECTED SAS CODE/*Create task order format*/ data addtaskn;
set process; taskord=_n_; format task $char22.; run;
set addtaskn(rename=(taskord=starttask=label)); fmtname='dataord'; type='N';
keep fmtname label start type;
proc format cntlin=taskordr;run;
/*Create Annotate Data Set to Draw Lines*/ data anno;
length function color $8; retain xsys ysys '2';
set addtaskn; line=linetype;
function='move'; x=begin; y=taskord; output; function='symbol';
if taskord=1 then do; text='U'; color="red"; end;
else if substr(task,1,1)=" " then do;text="D"; color="green"; end;
else do; text='P'; color="blue"; end; output;
function='draw'; size=4; x=end; y=taskord; output;
function='symbol'; style="marker"; size=1; end;
if taskord=1 then do; text='U'; color="red"; end; output;
/*Label top axis*/ data anno2; set dates(keep=date);
length function text $8 ;
retain xsys '2' ysys '3' color 'black' when 'a' size 1; line=1;
function='move'; x=date; y=90; output;
function='label'; x=date; y=90; text=left(monname); output;
function='label'; x=date; y=88; text=left(day(date)); output;
/* Set Titles, Symbols and Axes*/ title j=l box=1 bspace=0 bc=paoy "Consulting Proposal"; title3 " ";
axis1 label=none major=none minor=none value=(j=l h=1);
axis2 minor=none label=none major=none value=none style=0 order=("01Jul10"d to "01Jan10"d by month);
axis3 major=none minor=none label=none value=(j=l %days);
/*Plot the Timeline*/ proc gplot annotate=anno data=addtaskn;
plot taskord*end/frame vreverse vaxis=axis1 haxis=axis2 caxis=black anno=anno2 href="01Aug10"d "01Sep10"d "01Oct10"d "01Nov10"d "01Dec10"d lhref=34 cframe=white;
plot2 taskord*end/vaxis=axis3 vreverse;
format taskord dataord. end mmddyy10.;
footnote1 c=black 'Overall ' c=red font=marker height=1 'U' move=(-1,+0) draw=(+0,+.5,+1cm,+0) move=(+3.5,+0) "U" f=swiss c=black ' Summary ' c=blue font=marker height=1 'P' move=(-1,+0) draw=(+0,+.5,+1,+0) move=(+3.5,+0) "P" f=swiss c=black ' Activity ' c=green font=marker height=1 'D' move=(-1,+0) draw=(-1,+.5,+1cm,+0) move=(+3.8,+0) "D" c=black bc=paoy box=1 bspace=1;
EXAMPLE 3: WATERFALL CHARTSThe waterfall chart is ideal for displaying areas of loss or gain between starting and ending values. In general use, waterfall charts show how an initial value is increased and decreased by a series of intermediate values, leading to a final value. The advantage of displaying this type of information in a waterfall chart over a stacked bar chart is that, by isolating the subcategories of interest, the viewer's eye is drawn to the highlighted information. The waterfall chart is a relatively new graphic that has recently been popularized by McKinsey and Company for illustration of quantitative flows. In this paper, waterfall charts are created with two different methodologies.
EXAMPLE 3a: PHARMACY EXPENDITURE WATERFALLIn the first example, the waterfall chart shows the contributions to pharmacy costs by small, medium and large hospitals in a hospital system. This type of graph is often accomplished by creating an invisible column that keeps the increases and decreases linked to the heights of the previous columns. This method is the standard for Excel and is also demonstrated in a recent SESUG paper using Proc GHART to show cumulative campaign contributions (Booth, 2008).
/*Define axis characteristics */ axis1 major=none minor=none order=0 to 60 by 20 c=white value=(c=black) label=(c=black "Dollars in" j=r "Millions");
/*Add the title and title options*/ goptions ftitle='Arial' ftext='Arial' htitle=2 htext=1.4;run;
title 'Pharmacy Costs by Hospital Size';
/*Produce the Waterfall Chart */ proc gchart data=hospitals;
vbar period / discrete sumvar=cost raxis=axis1 autoref lref=34 cref=black subgroup=class cframe=cxe8e8e8 width=15 space=15 coutline=cxe8e8e8 nolegend;
format period yyq6. cost dollar4.0;
footnote1 move=(-12,0) f='Arial' h=1.1 box=1 c=green f=Marker 'U' c=black f='Arial' ' Small' c=yellow f=Marker ' U' c=black f='Arial' ' Medium' c=blue f=Marker ' U' c=black f='Arial' ' Large';
EXAMPLE 3b: HIGH RISK BIRTH WATERFALLIn this example, the waterfall chart shows a standard risk population, with the intermediate values as high risk populations. Waterfall charts do not need to have invisible columns. Here the bars are created in the annotate data set, which allows the beginning and ending points to be data driven. Because the bar is wider than a data point, it is necessary to use the offset option in the horizontal axis statement to move the starting bar to the right; otherwise the bar will overlap the vertical axis line. This example illustrates a waterfall chart with two categories. To add additional categories and colors, just add these to the color statement in the annotate data step. Regardless of the number of categories, no invisible column is created. For this reason, the GPLOT procedure is the base rather than GCHART.
This waterfall chart also differs from the earlier one in that the final bar is a summary bar, a common inclusion in waterfall charts.
/*Set Titles, Symbols and Axes*/ title "Type of Birth by Risk Factors";
axis1 order=("Low Risk" "Hypertension" "Diabetes" "Smoking" "Total") offset=(10,0) label = none style=0 ;