- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think you want to use VBARPARM instead where you specify the pre-calculated statistics.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Data?
Can't test code without data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry I was having trouble adding data - it's attached as a file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can see them on the graph though? Because I can't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I changed the code to reference the sashelp.cars data set and it works for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think you want to use VBARPARM instead where you specify the pre-calculated statistics.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you - this worked! Would there be a reason why the upper limit bar isn't being displayed though?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ah yes - thank you so much!