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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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