SAS 9.4 releases today with a ton of new features. As eloquently stated by Craig Rubendall, the driving themes are "Enable. Simplify. Innovate". The same sentiment applies to the ODS Graphics, with a ton of new features for the SG Procedures, GTL and ODS Graphics Designer.
In the next few articles, I will provide more details on specific features for all these graphics tools. Let us highlight some of the new features that will make it easier for you to make the graph you need.
In the category of new statements, we have added the AXISTABLE. This is a versatile new statement that makes it easy to display axis aligned text values in your graph. With Axis table, you can add columns of data on the left, right, bottom or top of any graph. Here is an example:
SAS 9.4 SGPLOT Code:
title "Monthly Temperatures Ranges for City"; proc sgplot data=weatherTable2 noautolegend; band y=month lower=low upper=high / transparency=0.6; scatter y=month x=high / markerattrs=graphdata1(symbol=circlefilled size=11) dataskin=sheen filledoutlinedmarkers; scatter y=month x=low / markerattrs=graphdata2(symbol=circlefilled size=11) dataskin=sheen filledoutlinedmarkers; yaxistable low high / label location=inside position=left; yaxistable lowc highc / label location=inside position=right; xaxis display=(nolabel) grid; yaxis display=(nolabel noticks) colorbands=odd colorbandsattrs=(transparency=0.9); run;
In this graph, we have used the following new features:
- Two YAXISTABLEs, one to place the data column on the left of the graph, and one on the right.
- Each axis table plots two columns from the data set.
- FilledOutlinedMarkers draw markers with a fill and outline.
- Skins are used to make markers glossy.
- Alternate color bands are used on the Y axis to help the eye across the page.
- I have trimmed some options for clarity and you can see the full code in the attached file.
Alternately, we can place all the column headers and axis tick values on one side (say the top) as shown here:
What are the use cases? Think Survival Plots with At-Risk tables, Lipid Profiles or Forest plots. The list is endless.
Another new feature is the ability to split long text values on white space for axis labels, axis tick values, data labels, curve labels, etc. This allows you to create nicer graphs such as the one shown below. Note the tick values on the X axis.
SAS 9.4 SGPLOT code:
title 'Cholesterol by Cause of Death'; proc sgplot data=sashelp.heart; vbar deathcause / response=cholesterol stat=mean dataskin=gloss; xaxis display=(nolabel); run;
The default tick value fit policy for GTL is ROTATE. So, if the tick value does not fit horizontally, it will be rotated at 45 degree angle. This has not changed. However, GTL has a new tick value fitting policy called SPLITROTATE. This policy will first try to fit the tick value with splitting. If it still does not fit, then it will rotate it. For SGPLOT, we have changed the default tick value fitting policy to SPLITROTATE. So, no new code is really needed to get this graph.
Another popular feature requested by users was JITTER. When X or Y axis is discrete, this option will arrange the markers in a row for observations whose response values fall within a threshold. Jittering can also be done for numeric axes.
SAS 9.4 SGPLOT code:
proc sgplot data=cars; scatter y=origin x=mpg_city / jitter markerattrs=graphdata1(size=11 symbol=circlefilled) filledoutlinedmarkers markeroutlineattrs=(thickness=0) dataskin=sheen; yaxis display=(nolabel); xaxis grid; run;
GTL now supports SGANNOTATE. The same data set that is currently used to define annotation for use with SG procedures can also be used with GTL. GTL also supports some extensions, allowing you to place the annotations in one of the layout containers by ID.
In this example, we have a GTL graph having two cells. We want to place specific annotations in each cell. The first cell has the text "Mileage by Origin and Type" rotated on the left side, and the second cell has the text "Distribution of Mileage" rotated on the right side with a border. Here is the graph.
SAS 9.4 GTL Code:
proc template; define statgraph CarStats; dynamic _min1 _max1 _min2 _max2; begingraph; entrytitle 'Vehicle Statistics'; layout lattice / columns=2; layout overlay / xaxisopts=(offsetmin=_min1 offsetmax=_max1) yaxisopts=(offsetmin=0); barchart x=origin y=mpg_city / stat=mean group=type groupdisplay=cluster dataskin=gloss; annotate / id='Bar'; endlayout; layout overlay / xaxisopts=(offsetmin=_min2 offsetmax=_max2) yaxisopts=(offsetmin=0); histogram mpg_city; densityplot mpg_city; annotate / id='Hist'; endlayout; endlayout; endgraph; end; run;
Note the two ANNOTATE statements, one in each cell, with two diferent ID values. The annotate data set has two observations, one for each text string, also with ID values. Only the annotate observations with the matching ID values are picked up for each statement. This allows you to define multiple annotation observations in the SGANNO data set, and pick and chose which one goes where. If ID is not used with the ANNOTATE statement, then all the annotation observations are rendered with the ANNOTATE statement.
Summary: SAS 9.4 brings you innovative new features to enable you to create the graphs you need with simpler code. This is a brief glance into some new features. In subsequent articles, we will talk about the graph features released with SAS 9.4 in greater detail.
Full SAS 9.4 code: SAS_94_Highlight