Hi there,
I am having trouble adding error bars to each bar in my vertical bar chart using Proc sgplot. First of all, is this even possible? Every discussion forum/questions never shows grouped bar charts. I have all the options on in my code to enable error bars but they are not being produced on the graph. My code is below - Is there a step I am missing?
Proc sgplot data=LSMTrtTOD1;
vbar TOD / response=Estimate stat=mean numstd=2 limitstat=stderr limits=both
group=Trt groupdisplay=cluster fillpattern nofill;
keylegend / position=top noborder;
yaxis grid;
Run;
Data?
Can't test code without data.
Sorry I was having trouble adding data - it's attached as a file.
Works fine for me - perhaps your errors are quite small? Note that not all bars have error bars, haven't investigated why but guessing it has to do with the N involved or to small to see.
Proc sgplot data=LSMTrtTOD1;
vbar TOD / response=Estimate stat=mean numstd=2 limitstat=stderr limits=both
group=Trt groupdisplay=cluster fillpattern nofill;
keylegend / position=top noborder;
yaxis grid;
Run;
@mcknigh3 wrote:
Hi there,
I am having trouble adding error bars to each bar in my vertical bar chart using Proc sgplot. First of all, is this even possible? Every discussion forum/questions never shows grouped bar charts. I have all the options on in my code to enable error bars but they are not being produced on the graph. My code is below - Is there a step I am missing?
Proc sgplot data=LSMTrtTOD1;
vbar TOD / response=Estimate stat=mean numstd=2 limitstat=stderr limits=both
group=Trt groupdisplay=cluster fillpattern nofill;
keylegend / position=top noborder;
yaxis grid;
Run;
You can see them on the graph though? Because I can't.
Thank you - this worked! Would there be a reason why the upper limit bar isn't being displayed though?
Proc sgplot data=LSMTrtTOD1 noborder;
vbarparm category=TOD response=Estimate / limitlower=stderr limitupper=stderr
group=Trt groupdisplay=cluster fillpattern nofill ;
yaxis grid Label= 'Daily distance (m)';
Run;
Sorry - I am pretty well new at this!
Ah yes - thank you so much!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.