turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- How to put error bars in vertical bars when using ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-02-2012 07:56 PM

Hello,

I need to put top error bars on my vertical bar charts. I am using porc gchart and have to use Subgroup option. I am getting the following warning when I use errorbar=top option "WARNING: Error bars are not supported when SUBGROUP= is specified.".

Can anyone please help me?

Thanks,

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-03-2012 12:02 PM

To render this graph, you would need to compute the standard error for the entire bar and overlay the error bars as a separate plot. I can show you how to do this using the Graph Template Language (GTL) if you have SAS 9.2 or greater. What version of SAS do you have?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-03-2012 12:58 PM

Thanks for the reply. I use 9.2, if possible can you give me the idea how to use GTL?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-05-2012 02:13 PM

Hi Dan,

I will really appreciate if you can give me an example of how to create standard error bars on bar graphs with subgroup as an option using GTL when working in SAS 9.2?

Thanks

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-05-2012 03:29 PM

Sorry, I forgot to get with you on this. I've put together a little example below. The tricky part is not the graph template -- it's getting the data correct to draw the error bars in the correct location. In the example below, the stderr is computed in PROC SUMMARY, but is later modified to position the error bar correctly at the top of the bar. Let me know if you have any questions about it.

Thanks!

Dan

`/* First, all data used for the overlay must be summarized */`

proc summary data=sashelp.class nway;

class age;

var height;

output out=limits sum=limitsum stderr=stderr;

run;
proc summary data=sashelp.class nway;

class age sex;

var height;

output out=subgroups sum=barsum;

run;

data limits2;

rename age=age2;

set limits (keep=age stderr limitsum);

ustderror = limitsum + stderr;

lstderror = limitsum - stderr;

run;

data merged;

merge subgroups limits2;

run;

/* The graph template */

proc template;

define statgraph barlimits;

begingraph;

layout overlay;

barchartparm x=age y=barsum / group=sex primary=true;

scatterplot x=age2 y=limitsum / yerrorupper=ustderror yerrorlower=lstderror markerattrs=(size=0);

endlayout;

endgraph;

end;

run;

proc sgrender data=merged template=barlimits; run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-08-2012 12:08 AM

Thank you Dan. The code you sent me worked.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-20-2012 05:17 PM

Dear Dan,

Thanks a lot for answering my query regarding plotting the error bars in vertical bars.

Can you please help me if there is a way I can specify colors for each bar? I did some Google research but I can't find the solution to it. Does goptions work here too?

Thanks a lot for your help.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-05-2012 06:40 PM

A more general question is "is a bar chart with a confidence interval a good way to display these data." A discussion of this question is available at

http://blogs.sas.com/content/iml/2011/10/07/creating-bar-charts-with-confidence-intervals/