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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.