BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Barkat
Pyrite | Level 9

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
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26

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?

--
Paige Miller
Barkat
Pyrite | Level 9

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

Quentin
Super User

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

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Reeza
Super User

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;
Barkat
Pyrite | Level 9

Thanks so much! Is it possible to change color of the bars or lines for confidence intervals?

Reeza
Super User

Yes, take a look at the documentation for specifications or data attribute maps.

Barkat
Pyrite | Level 9
I can't seem to understand it. When I use fillattrs=(color=blig), it changes color of both types of bars. How can I choose two colors for two types of bars?
Reeza
Super User
You specified only one colour in the parenthesis. What happens if you specify two colours?

See discrete map example here:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm
Barkat
Pyrite | Level 9
It ignores the second color, if I mention two colors in the parentheses.
Reeza
Super User
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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 11 replies
  • 1614 views
  • 4 likes
  • 4 in conversation