How can I create a graph or chart to display sensitivity and specificity with 95% confidence intervals of multiple screening tests?
Name of Tests | Sn | Sp | Lower limit of 95% CI | Upper limit of 95% CI |
A | 60% | 70% | 0.45 | 0.98 |
B | 70% | 75% | 0.75 | 0.95 |
C | 80% | 80% | 0.82 | 1.00 |
I don't recommend that graphic either, forest plots will definitely be nicer.
data have;
informat sn sp percent.;
infile cards dlm='09'x;
input group $ sn sp sn_ll sn_ul sp_ll sp_ul;
cards;
X 60% 70% 0.45 0.98 0.50 0.90
Y 70% 75% 0.35 0.95 0.40 0.90
Z 80% 80% 0.62 1.00 0.50 1.00
;;;;
run;
data long;
set have;
type = "Sensitivity";
value = sn;
ll = sn_ll;
ul = sn_ul;
output;
type = 'Specificity';
value = sp;
ll = sp_ll;
ul = sp_ul;
output;
drop sn: sp:;
run;
proc sgplot data=long;
vbarparm category=group response = value / limitlower=ll limitupper=ul group=type groupdisplay=cluster;
run;
proc sgplot data=long;
highlow x=group high=ul low = ll / group = type open =value groupdisplay = cluster;
run;
What would such a chart look like? Can you point us to an example somewhere on the internet? Or draw it somehow and show us?
I should have added two more columns to the hypothetical table. I have revised the 95% CI values to make it more realistic.
Name of Tests | Sn | Sp |
Lower limit of 95% CI for Sn |
Upper limit of 95% CI for Sn |
Lower limit of 95% CI for Sp |
Upper limit of 95% CI for Sp |
X | 60% | 70% | 0.45 | 0.98 | 0.50 | 0.90 |
Y | 70% | 75% | 0.35 | 0.95 | 0.40 | 0.90 |
Z | 80% | 80% | 0.62 | 1.00 | 0.50 | 1.00 |
Please see the graph in the link, (1) graph with error bars - Bing images
Think, the red and blue bars as Sn and Sp, respectively. The lines as 95% CI. d16 as Test X, d20 as Test Y, and d21 as Test Z
I don't think I'd do that as a bar chart. I might try a forest plot, basically a dot plot with intervals on each dot.
Here are a few graphing blogs from gurus at SAS that might help, with examples of bar charts and dot plots
https://blogs.sas.com/content/graphicallyspeaking/2017/10/22/tips-tricks-segmented-discrete-axis/
https://blogs.sas.com/content/graphicallyspeaking/2012/01/12/custom-confidence-intervals/
https://blogs.sas.com/content/iml/2011/10/07/creating-bar-charts-with-confidence-intervals.html
I don't recommend that graphic either, forest plots will definitely be nicer.
data have;
informat sn sp percent.;
infile cards dlm='09'x;
input group $ sn sp sn_ll sn_ul sp_ll sp_ul;
cards;
X 60% 70% 0.45 0.98 0.50 0.90
Y 70% 75% 0.35 0.95 0.40 0.90
Z 80% 80% 0.62 1.00 0.50 1.00
;;;;
run;
data long;
set have;
type = "Sensitivity";
value = sn;
ll = sn_ll;
ul = sn_ul;
output;
type = 'Specificity';
value = sp;
ll = sp_ll;
ul = sp_ul;
output;
drop sn: sp:;
run;
proc sgplot data=long;
vbarparm category=group response = value / limitlower=ll limitupper=ul group=type groupdisplay=cluster;
run;
proc sgplot data=long;
highlow x=group high=ul low = ll / group = type open =value groupdisplay = cluster;
run;
Thanks so much! Is it possible to change color of the bars or lines for confidence intervals?
Yes, take a look at the documentation for specifications or data attribute maps.
proc sgplot data=long;
styleattrs datacolors=(cx9999ff cx993366);
vbarparm category=group response = value / limitlower=ll limitupper=ul group=type groupdisplay=cluster;
run;
Use STYLEATTRS but if you're missing a category you MUST use data attribute maps.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.