BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Melk
Lapis Lazuli | Level 10

I am running a vertical bar chart for stat=median and would like an upper error bar to represent the 3rd quartile of the IQR. Is there a way to do this? I think error bars are only displayed when stat = mean?

 

proc sgplot data=dat;
    vbar x/ response=y stat=median;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

For such custom situations, you will need to compute the median and 3rd quartile values by category using PROC MEANS.  Then you can use vbarparm to plot the bar chart of median by category and overlay a scatter of median by category with upper x-error bar to display the quartile.  You can set the scatter marker size to zero.

View solution in original post

2 REPLIES 2
Jay54
Meteorite | Level 14

For such custom situations, you will need to compute the median and 3rd quartile values by category using PROC MEANS.  Then you can use vbarparm to plot the bar chart of median by category and overlay a scatter of median by category with upper x-error bar to display the quartile.  You can set the scatter marker size to zero.

ballardw
Super User

Or using more of a "draw" it approach using NEEDLE statement with pre-summarized data:

 

proc summary data=sashelp.class nway;
   class sex;
   var weight;
   output out=plot (drop=_:) median= Q3= /autoname;
run;

   
proc sgplot data=plot;
  needle x=sex y=weight_q3 /markers markerattrs=(symbol=tack);
  vbarparm category=sex response=weight_median/ name='bar';
  keylegend 'bar';
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1959 views
  • 0 likes
  • 3 in conversation