SGPLOT can do this, but the bar segments are side by side (GROUPDISPLAY=CLUSTER)
If you want the stacked bar then you need to calculate the values up front and use VBARPARM together with the HIGHLOW plot statements.
Here is an example ussing SASHELP.CARS
/*
* generate test data
*/
data cars;
set sashelp.cars;
where
origin in ("Asia", "USA")
and not (type = "Hybrid")
;
/*
* choose which var to use
*/
value = horsepower;
format value comma12.;
run;
/*
* what you get for free
*/
ods graphics / width=1200 height=900;
proc sgplot data=cars;
vbar type /
group=origin
response=value
stat=mean
limits=both
limitstat=stddev
groupdisplay=cluster
seglabel
;
run;
/*
* calculate mean and std
*/
proc sql;
create table cars_limits as
select
type
, origin
, mean(value) as mean_value format=comma12.
, std(value) as std_value format=comma12.
from
cars
group by
type
, origin
order by
type
, origin
;
quit;
/*
* compute values used with highlow stmt
*/
data cars_limits2;
set cars_limits;
by type;
mean_value2 = lag1(mean_value);
if origin = "Asia" then do;
a_ll = mean_value - (1 * std_value);
a_ul = mean_value + (1 * std_value);
end;
if origin = "USA" then do;
b_ll = mean_value2 + ( mean_value - (1 * std_value) );
b_ul = mean_value2 + ( mean_value + (1 * std_value) );
end;
run;
/*
* create graph
*/
proc sgplot data=cars_limits2;
vbarparm category=type response=mean_value / group=origin groupdisplay=stack seglabel;
highlow x=type low=a_ll high=a_ul / group=origin lowcap=serif highcap=serif lineattrs=(color=cx000000);
highlow x=type low=b_ll high=b_ul / group=origin lowcap=serif highcap=serif lineattrs=(color=cx000000);
run;
... View more