Graphically Speaking

Should we move to Ireland?

Recently, while browsing health care data, I came across the graph shown below. The graph includes the healthy life expectancy at birth by countries in the EU, along with the associated per capita expenditure. The graph also shows estimate of potential gain in life expectancy by increasing expenditure efficiency.

SAS Guide, SAS Tutorials and Materials, SAS Certifications

The graph has some interesting characteristics, so I thought it would be interesting to see how easy it is to make the same chart using SGPLOT procedure. The first task was to enter some of the data into a SAS data set, and I did that for about half of the countries, enough to proceed with the graph. Here is the graph and the code. See the linked program at bottom for full code.

SAS Guide, SAS Tutorials and Materials, SAS Certifications

title ‘A closer look at relative efficiency in EU healthcare systems’;
footnote j=l h=7pt italic bold ‘* According to Heijink R. et al, adjusted for the impact of lifestyle differences,’
‘ such as smoking and alcohol consumption (2015)’;
proc sgplot data=efficiency2 noborder;
styleattrs datacolors=(%rgbhex(91,187,229) %rgbhex(59,138,197) %rgbhex(233,68,147))
axisextent=data;
vbarparm category=country response=Value / group=cat groupdisplay=stack
outlineattrs=(color=white) barwidth=0.7
baselineattrs=(thickness=0) filltype=gradient;
vbarparm category=country response=expense / barwidth=0.3 y2axis
outlineattrs=(color=white)
baselineattrs=(thickness=0);
yaxis label=’Healthy life expectancy at birth in years’ values=(0 to 90 by 10)
offsetmax=0.2 labelposition=datacenter;
y2axis label=’Health care expentiture per capita’ values=(0 to 4500 by 500)
offsetmax=0.2 labelposition=datacenter;
xaxis display=(noline noticks nolabel);
keylegend / across=1 noborder;
inset ‘Member States achieve very different levels of health outcomes for the same money spent.’
‘ All Member States could have better results without spending more and by increasing ‘
‘expentiture efficiency.’ / textattrs=(size=7pt) position=top;
run;

In this program, I used the macro %rgbhex() by Perry Watts to match the colors.

On first view, the “Gain in life expectancy” bar segments look smaller in my graph. Then, on closer examination, one can see that the original graph sets the y axis min=50, causing the bar segments to get longer. This could actually distort the perception of life expectancy vs gain and expense, as the y2 axis min=0. In my graph, both y axes are zero based.

Also, we should note that the relative lengths of the blue and red bars have no significance, as the axis values on Y and Y2 are very different, and different between the graphs.

The original graph data is sorted by descending “Healthy life expectancy at birth”. I thought it may be useful to also view the same data sorted by per capita expense. So, I sorted the data and the new graph is shown below.

SAS Guide, SAS Tutorials and Materials, SAS Certifications

In this graph, we can really appreciate the difference in per capita expense between the countries. Also, the countries with lower expense still seem to enjoy a pretty good life expectancy. Actually, Ireland and Spain have relatively low expense, and the high life expectancy (amongst the EU contries in my graph)!

Full SGPLOT code:

 

%let gpath=C:\;
ods html close;
%let w=5in;
%let h=3.5in;
%let dpi=200;
ods listing gpath=”&gpath” image_dpi=&dpi;

/*–Macro by Perry Watts–*/
%macro RGBHex(rr,gg,bb);
%sysfunc(compress(CX%sysfunc(putn(&rr,hex2.))
%sysfunc(putn(&gg,hex2.))
%sysfunc(putn(&bb,hex2.))))
%mend RGBHex;

/*–Key in some data–*/
data efficiency;
input Country $ AtBirth Gain Expense;
datalines;
IE     81    4    2000
MT   80   4    2200
ES    79    5    2000
NL    79   3    3200
SE    79    4    2500
UK   79   4    2450
FL    78   4    2450
DE   77    5    3550
FR   76    6    3050
EL   75.5  4   2000
LU   76     6   3250
AT   76     6   2900
CY   75.5  3   1600
DK  75.5  6   3000
;
run;

data efficiency2;
label expense=’Health care expense per capita’;
length Cat $80;
set efficiency;
Cat=’Healthy life expectancy at birth *’; Value=AtBirth; output;
Cat=’Potential gains in healthy life expectancy w/o increase in health care expense’;
Value=Gain; Expense=.; output;
run;
/*proc print;run;*/

/*–Graph sorted by life expectancy at birth–*/
ods graphics / reset width=&w height=&h noborder imagename=’EU_Efficiency’;
title ‘A closer look at relative efficiency in EU healthcare systems’;
footnote j=l h=6pt italic bold ‘* According to Heijink R. et al, adjusted for the impact of lifestyle differences,’
‘ such as smoking and alcohol consumption (2015)’;
proc sgplot data=efficiency2 noborder;
styleattrs datacolors=(%rgbhex(91,187,229) %rgbhex(59,138,197) %rgbhex(233,68,147))
axisextent=data;
vbarparm category=country response=Value / group=cat groupdisplay=stack
outlineattrs=(color=white) barwidth=0.7
baselineattrs=(thickness=0) filltype=gradient;
vbarparm category=country response=expense / barwidth=0.3 y2axis
outlineattrs=(color=white)
baselineattrs=(thickness=0);
yaxis label=’Healthy life expectancy at birth in years’ values=(0 to 90 by 10)
offsetmax=0.2 valueattrs=(size=6) labelattrs=(size=7) labelposition=datacenter;
y2axis label=’Health care expentiture per capita’ values=(0 to 4500 by 500)
offsetmax=0.2 valueattrs=(size=6) labelattrs=(size=7) labelposition=datacenter;
xaxis display=(noline noticks nolabel) valueattrs=(size=6 weight=bold);
keylegend / across=1 noborder valueattrs=(size=7);
inset ‘Member States achieve very different levels of health outcomes for the same money spent.’
‘ All Member States could have better results without spending more and by increasing ‘
‘expentiture efficiency.’ / textattrs=(size=7pt) position=top;
run;

/*–Sort by Expense–*/
proc sort data=efficiency out=efficiency_by_expense;
by descending expense;
run;

data efficiency3;
length Cat $80;
label expense=’Health care expense per capita’;
set efficiency_by_expense;
Cat=’Healthy life expectancy at birth *’; Value=AtBirth; output;
Cat=’Potential gains in healthy life expectancy w/o increase in health care expense’;
Value=Gain; Expense=.; output;
run;
/*proc print;run;*/

/*–Graph sorted by expense–*/
ods graphics / reset width=&w height=&h noborder imagename=’EU_Efficiency_by_Expense’;
title ‘A closer look at relative efficiency in EU healthcare systems’;
footnote j=l h=6pt italic bold ‘* According to Heijink R. et al, adjusted for the impact of lifestyle differences,’
‘ such as smoking and alcohol consumption (2015)’;
proc sgplot data=efficiency3 noborder;
styleattrs datacolors=(%rgbhex(91,187,229) %rgbhex(59,138,197) %rgbhex(233,68,147))
axisextent=data;
vbarparm category=country response=Value / group=cat groupdisplay=stack
outlineattrs=(color=white) barwidth=0.7
baselineattrs=(thickness=0);
vbarparm category=country response=expense / barwidth=0.3 y2axis
outlineattrs=(color=white)
baselineattrs=(thickness=0);
yaxis label=’Healthy life expectancy at birth in years’ grid values=(0 to 90 by 10)
offsetmax=0.2 valueattrs=(size=6) labelattrs=(size=7) labelposition=datacenter;
y2axis label=’Health care expentiture per capita’ values=(0 to 4500 by 500)
offsetmax=0.2 valueattrs=(size=6) labelattrs=(size=7) labelposition=datacenter;
xaxis display=(noline noticks nolabel) valueattrs=(size=6 weight=bold);
keylegend / across=1 noborder valueattrs=(size=7);
inset ‘Member States achieve very different levels of health outcomes for the same money spent.’
‘ All Member States could have better results without spending more and by increasing ‘
‘expentiture efficiency.’ / textattrs=(size=7pt) position=top;
run;

title;
footnote;
/*–Icon–*/
ods listing image_dpi=100;
ods graphics / reset width=2.7in height=1.8in imagename=’EU_Icon’;
title ‘A closer look at relative efficienty in EU healthcare systems’;
proc sgplot data=efficiency3 noborder;
styleattrs datacolors=(%rgbhex(91,187,229) %rgbhex(59,138,197) %rgbhex(233,68,147))
axisextent=data;
vbarparm category=country response=Value / group=cat groupdisplay=stack
outlineattrs=(color=white) barwidth=0.7
baselineattrs=(thickness=0);
vbarparm category=country response=expense / barwidth=0.3 y2axis
outlineattrs=(color=white)
baselineattrs=(thickness=0);
yaxis label=’Healthy life expectancy’ values=(0 to 90 by 10)
grid gridattrs=(pattern=solid);
y2axis label=’Health care expense’ values=(0 to 4500 by 500);
xaxis display=(noline noticks nolabel) valueattrs=(size=7) fitpolicy=none;
keylegend / across=1 noborder;
run;

title;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s