BookmarkSubscribeRSS Feed
sfo
Quartz | Level 8 sfo
Quartz | Level 8

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,

7 REPLIES 7
DanH_sas
SAS Super FREQ

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?

sfo
Quartz | Level 8 sfo
Quartz | Level 8

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

sfo
Quartz | Level 8 sfo
Quartz | Level 8

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

DanH_sas
SAS Super FREQ

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;

sfo
Quartz | Level 8 sfo
Quartz | Level 8

Thank you Dan. The code you sent me worked.

sfo
Quartz | Level 8 sfo
Quartz | Level 8

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.

Rick_SAS
SAS Super FREQ

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/

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 2605 views
  • 3 likes
  • 3 in conversation