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;
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.
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.
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.