BookmarkSubscribeRSS Feed
Dieter
Calcite | Level 5

Dear all,

 

When adding 'subgroup' to the gchart options, in order to allow bars have pre-defined patterns, the error bars are suddenly wrongly calculated. I do not know what the reason would be, and how to solve the problem for this simple graph...

All help more than welcome

 

(A) below the code and barchart without subgroup, and correctly calculated error bars:

 

correct error bars.png

 

 

goptions reset=all;
proc gchart data = cornell.transweightfinalchart;
legend label=(h=1.5) VALUE=(h=1.5);
axis1 label=(f='Times new roman/bo' h=2 a=90 "Larva (mg)" ) order=(0.36 to 0.52 by 0.02) value=(h=1.5) minor=(n=1);
axis2 label=none value=(h=2 f='Times new roman');
axis3 label=none value=(h=2 f='Times new roman/bo');
vbar Treatment/
group=Experiment
sumvar=L
errorbar=top
clm=68.26
width= 8
space= 1
gspace= 3
legend= legend
type=mean
raxis= axis1
maxis=axis2
gaxis=axis3;
where treatment ne '';
run;
quit;

 

 

(B) Below a subgroup, named 'Treatment' is added in order to adjust the pattern of the bar that represents either the the Cont. or the Infect. group (i.e. also pattern1 and pattern2 has been added). Error bars: not correct

 

 

wrong error bars.png

 
goptions reset=all;
proc gchart data = cornell.transweightfinalchart;
pattern1 v=solid color=graycc;
pattern2 v=solid color=cx437193;
legend label=(h=1.5) VALUE=(h=1.5);
axis1 label=(f='Times new roman/bo' h=2 a=90 "Larva (mg)" ) order=(0.36 to 0.52 by 0.02) value=(h=1.5) minor=(n=1);
axis2 label=none value=(h=2 f='Times new roman');
axis3 label=none value=(h=2 f='Times new roman/bo');
vbar Treatment/
group=Experiment
sumvar=L
errorbar=top
clm=68.26
subgroup=Treatment
width= 8
space= 1
gspace= 3
legend= legend
type=mean
raxis= axis1
maxis=axis2
gaxis=axis3;
where treatment ne '';
run;
quit;
 
 
What did I do wrong?
 
Many thanks in advance.
 
 
2 REPLIES 2
DanH_sas
SAS Super FREQ

Take away the SUBGROUP and add PATTERNID=MIDPOINT to see if you get what you expect.

 

Hope this helps!

Dan

Dieter
Calcite | Level 5

Wow Dan,

this is THE solution, indeed!  I do not know why, but it worked.

Thank you so much!

 

Dieter

 

 

 

correct error bars with correct pattern.png

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 589 views
  • 1 like
  • 2 in conversation