Sparklines Created in

I have been following Professor Tufte's work since he first came to my attention about a year ago. I really like the simplicity and power of sparklines. Since I am a statistician, I use SAS in my daily work. So, I thought it would be useful to find a way to make sparklines in SAS from a SAS data set since there are many other statisticians out there using SAS. The more formats that the creation of sparklines are offered in, the more accepted they will become.

I have put together a SAS macro for PC SAS that allows the user to create sparklines by using a SAS data set with the data points arranged in one of the columns. The macro allows the user to select the trend or bar type of sparkline and allows the choice of marking the maximum and minimum on a trend sparkline. Although I have been programming in SAS for over 8 years, I am not an expert in SAS/GRAPH, so any recommendations for improvements to the macro would be appreciated. Currently the user is restricted to 11 characters for the descriptive word that appears to the right of the sparkline. The output appears in the SAS graph output Window. My recommendation is to right-click on the output, choose File>Export As Image... and save the output as an image. I have been having good luck with PNG files. You will notice that the font appears rather large, as does the red dot representing the current value, but this is necessary so that when the file is reduced and put into a document, it looks right. Unfortunately there is one additional manual step: you need to open the PNG (or other picture format) file and cut out just the narrow sparkline portion to insert in a document.

Click here to view a PDF of a Word document showing what the sparklines created in SAS look like in use. As usual, the print resolution is much better than that on your monitor. Below are close up views of the sparklines that give a better feel for what they really look like.

The sparklines below were created in SAS using the code found here. The first data step creates a sample data set to test the macro and was used to produce the first three sparklines below. The only code needed is below that data step.

Close-up of a trend sparkline

Close-up of a trend sparkline

Close-up of a bar sparkline

Close-up of a bar sparkline