Hands on SAS Graphics Course in Basel

Kriss Harris SFSI would like to thank Syntax for Science for organising the following course, Design of statistical graphs in clinical studies: theory and practice with SAS Graphic Template Language.  The course was hosted in Basel and took place in November 2014.

A wealth of useful information relating to the theory of graphics took place on the morning of Day 1. Jenny Freeman from Leeds University presented on Good Practices in Graphics Design. Andreas Krause from Actelion Pharmaceuticals presented on Graphics of Clinical Data: the good, the bad, and the ugly. Ian Cox from JMP at SAS presented on Make it Easy: exploring data with SAS JMP.

In the afternoon of Day 1, Phillip Holland from Holland Numerics, gave an Introduction to SG Procedures and Graphics Template Language (GTL).  I learned many useful tips in Phils presentation and at the end of his presentation, I felt it was necessary to purchase his book Power User’s Guide to Graph Template Language.

On Day 2 of the course, I presented the Hands on SAS Graphics Course section. The “Hands on” entailed me showing and describing how the SAS code (typically in version 9.3) can be used to produce the desired output. There was also a fun impromptu section were the participants and I had to figure out the SAS code that Dan Heath and Sanjay Matange used to produce their outputs in the Graphic Samples Output Gallery.

The code that was used in the Hands On SAS Graphics section can be accessed here. The datasets that were used in the presentation can be accessed here. Finally, the presentation can be accessed here.

Please help with color in histogram

A few days ago I was asked how to change the fill color of the histogram bars to light green when using Proc UNIVARIATE. The person did try to use the cfill option, however this does not work with ods graphics. They also created a template and specified the color green. However they wanted light green. In the end they produced this graph.


The above graph is a really good attempt actually and they decided to contact me because they discovered the SAS 9.2 Graphics Course on line which I created and gave a few years ago.

I knew exactly how to change the color of the histogram bars to light green and this is because of the knowledge I gained on specifying hexadecimal colors and on modifying style templates which I mainly learned from the book Statistical Graphics in SAS: An Introduction to the Graph Template Language and the Statistical Graphics Procedures by Warren Kuhfeld.

Without further ado, below is the image I created.



I used the website http://www.colorpicker.com to help decide on the shade of green to select, and modified the Statistical template with the required change. Please see the code below that was used.

data Trans;
input Thick @@;
label Thick = ‘Plating Thickness (mils)';
3.468 3.428 3.509 3.516 3.461 3.492 3.478 3.556 3.482 3.512
3.490 3.467 3.498 3.519 3.504 3.469 3.497 3.495 3.518 3.523
3.458 3.478 3.443 3.500 3.449 3.525 3.461 3.489 3.514 3.470
3.561 3.506 3.444 3.479 3.524 3.531 3.501 3.495 3.443 3.458
3.481 3.497 3.461 3.513 3.528 3.496 3.533 3.450 3.516 3.476
3.512 3.550 3.441 3.541 3.569 3.531 3.468 3.564 3.522 3.520
3.505 3.523 3.475 3.470 3.457 3.536 3.528 3.477 3.536 3.491
3.510 3.461 3.431 3.502 3.491 3.506 3.439 3.513 3.496 3.539
3.469 3.481 3.515 3.535 3.460 3.575 3.488 3.515 3.484 3.482
3.517 3.483 3.467 3.467 3.502 3.471 3.516 3.474 3.500 3.466
proc template ;
define style Styles.newstyle;
parent = Styles.statistical;
style GraphDataDefault from GraphDataDefault /Color = cx00FF00;
/* This color specifies light green and codes can be found from the website http://www.colorpicker.com */

ods graphics on / reset = all imagename =”image” width = 3in height = 2in ;
ods html style = styles.default;
ods listing style = styles.newstyle gpath = “C:\Users\Kriss\Documents\Graphs” dpi = 300;
goptions reset=all border;
title ‘Analysis of Plating Thickness';
proc univariate data=Trans noprint;
histogram Thick;

Afterwards, I was asked how to make the background of the graph yellow, and this is done by adding in this code to the template:

style GraphBackground from GraphBackground /color = yellow;




PharmaSUG China 2013

I had a really good time at PharmaSUG China 2013. The only thing was I had a really hard time attending the conference! For some reason I didn’t think I needed to have a visa to gain entry into Shanghai, and only found out after I reached Heathrow Airport. At first I was told that I would have to rebook the flight again in at least 4 days! I replied “the conference would be over by then though”.

After further enquiries I found out that I could go to Hong Kong and obtain a Chinese visa from there within “4 hours”. So I persevered on, and was on my way to Hong Kong, which was an amazing place and well worth the visit! Unfortunately instead of 4 hours for the visa I had to wait 24 hours in the end, and I’m very grateful for Leo Li, Margaret Hung and James Wu for rearranging the presentation I was giving from Friday 6 September 2013 to the day after.

Picture of the Hong Kong Harbour

Anyway back to my PharmaSUG China. There was a wealth of presentations available. The paper I presented on Creating High Quality Statistical Graphs for Publications seemed to be received quite well, and I had interesting discussions at question time, and right after my presentation too at Lunch time.

Creating High Quality Statistical Graphics for Publications

I left the conference really intrigued after hearing the last presentation at the conference which was a panel discussion. This entailed the likes of Art Carpenter, Eckhard Pecker, Eric Deng, Sy Truong, Tracey Turschman and Zibhao Zhang answering some really interesting industry topics. Such as how do they see the future for SAS Programmers, and what will SAS Programmers have to learn? This panel was moderated exceptionally well by Yanyun Shen, and the main things I picked up was that SAS Programmers in the pharmaceutical industry should be employable for a long while. There is so much data out there, and China especially has a younger marker than the West and therefore, more businesses are going to be coming to China. To be a proficient SAS Programmer we will need to be flexible and not just rely on “One Procedure” to see us through to retirement. We should be learning other procedures, and it is even better for us if we can learn how to program those “Push a button” macros. Furthermore it will be useful for us to learn other languages such as R and XML; More and more data is on the web.

Finally when the conference closed, I found out that I won a prize! A prize! This is the first time I have ever one a prize, and that means my conference fees for PharmaSUG China 2014 which will be held in Beijing, will be paid for!

Insanity Fit Test Results

As I’m sure you know, I’m really into fitness.  Therefore I decided to try Insanity by Shaun T late December 2012. Below are my fitness test results over the 60 days and as you can see I’ve really digged deep!

 Insanity Fit Test Results








Below are the results for the percentage change from my first fitness test. As you can see my Push-up Jacks and Power Jumps increased by at least 100% in some of the fit tests compared to my first week.



Trellised Waterfall Plot for % Change in Tumor Size from baseline at Visit 2 by Treatment using SAS 9.2

Here is some code for a plotting a Trellised Waterfall Plot for % Change in Tumor Size from baseline at Visit 2 by Treatment using SAS 9.2.

Below is an example of how the figure looks.

Waterfall Plot for % Change in Tumor Size from baseline at Visit 2 coloured by group using SAS 9.2

Here is some GTL code to produce a Waterfall Plot for % Change in Tumor Size from baseline at Visit 2 coloured by group using SAS 9.2.

The figure below does not seem so advance at first howerver, there are a lot of things going on. Firstly the x-axis is ordered by decreasing % change from baseline. Secondly, the subjects are coloured by another variable (Group), and thirdly the percentage changes are shown on top of or below the bar charts. Enjoy!

Statistical Graphics Procedures by Example: Effective Graphs Using SAS by Dan Heath and Sanjay Matange – Review

Here is my Amazon Review on Statistical Graphics Procedures by Example: Effective Graphs Using SAS by Dan Heath and Sanjay Matange

If you’re anything like me, I have been keeping up with the advancements of SAS Graphics by Googling SAS Global Forum (SGF), SGPLOT, and Graphics etc. and beside either typing Sanjay Matange or Dan’s Heath name. As a consequence I’ve got lots of Dan’s and Sanjay’s SGF Paper as my favorites, and inevitably have become quite good at creating Graphics :)

This book is the end of storing multiple graphical favorites, searching the internet for help, and wondering how to plot good quality graphs with ease! This book is mostly for SAS 9.2 users and goes through the basics of the “new” SG Procedures step by step really well. It shows you how to create nice single cell plots, and describes plot types that can be overlaid and go together, such as a scatterplot and a regression line. It also shows you how to produce paneled plots (multiple plots on one page) which is a well sought after plot, amongst other things. This book touches on the new graphical options in SAS 9.3 and touches on the more advanced techniques, such as attribute maps, which is a really neat way to plot grouped data exactly how you want it, regardless of any missing groups.

I liked that there were specific plot templates based on the business you were in. I found the Health and Life Sciences Chapter really helpful, which showed how to create Forest plots with Summary Statistics and Adverse Events Timeline graphs. Towards the end of the book it gave details on the graph image types that were available, and the pros on cons of each. This was great as it has been an increasing subject of interest.

The only downsides of this book is I would have liked it to also have talked about the DISCRETEOFFSET option in terms of Jittering plots at the lowest level (such as Subject ID) too, and talked more about SGRender and Graph Template Language (GTL). However with regards to talking more about GTL, this is based on the knowledge I know the authors have on the subject and I can imagine the difficulty in actually incorporating GTL as it is a huge subject and there is a steeper learning curve than learning SGPLOT, SGPANEL and SGSCATTER which this book is focused on too.

I recommend this book for anyone that wants to learn the basics and foundations of producing, nice publication ready graphics easily in SAS 9.2 or 9.3 or for any other intermediate or advanced graphical user that would like to sharpen their graphical skills.

Graphing Bench Press Statistics with SAS SGPLOT and SGPANEL

Outside of my work environment, I am a big user of the gym! I have been tracking my Flat Bench Press Statistics since August, and have now thought of a few good ways to plot my progress.

The graph below shows the maximum weight I bench pressed within my workouts, and I’ve gone from 90kg to 120kg in 3 months!

Please click on the image to make it clearer!

Maximum Weight I Bench Pressed within my workouts

Another way to look at my progress is to include the average weights I bench pressed. This is done by using the Band Statement in SGPLOT.

Average and Maximum Weight Range I Bench Pressed

It’s also good to see the actual amount of Reps and Sets that were done at each weight throughout the weeks! This is demonstrated with SGPANEL. You can see that in August I was bench pressing around 7 reps maximum of 90kg, and within a few months (Novemeber) this went up to 7 reps of 100kg! I’m very proud of this! One of my targets are to do 10 reps of 100kg (2 plates), and then another target is to do 1 rep of 140kg (3 plates)

Actual Reps and Sets I Bench Pressed

I keep you updated on my progress!

SAS 9.2 Graphics Course in Prezi

Please look at the Prezi presentation of the SAS 9.2 Graphics Course. Your comments would be greatly appreciated!

SAS 9.2 Graphics Course

Here is a SAS 9.2 Graphics Course and the code which shows you how to use the SGPLOT, SGPANEL, SGSCATTER, SGRENDER, and Graph Template Language to produce high quality graphs with simple code.