The SAS Output Delivery System and reporting techniques

Fast/Easy way to display Geometric Mean in a boxplot?

Reply
Contributor VCM
Contributor
Posts: 22

Fast/Easy way to display Geometric Mean in a boxplot?

I have inherited a general boxplot program (V9.4) that displays the mean.  I need to update to reporting the geometric mean.

 

The current program is using a boxplot statement in PROC TEMPLATE, which is then called in PROC SGRENDER:

 

proc template;
define statgraph XXX;
begingraph ;

...blah blah axis options and titles and whatnot...

boxplot y=yvar x=xvar / datalabelattrs=(color=black size=4) boxwidth=0.25 display=(caps fill median mean outliers);

endlayout;

endgraph;
end;
run;

proc sgrender data=mydata template = XXX;
run;
quit;

 

I'm not finding any options to display geometric means.  I'm poking around at using PROC SGPLOT instead with VBOX, but I'm not finding any options there either.

 

Unless there is some awesomely cool proc or option I'm missing, I'm thinking my best bet may be to suppress printing the mean, calculate geo-mean, and overlay it separately.  Any suggestions?

 

 

Many many thanks,

VCM 

Super User
Posts: 24,026

Re: Fast/Easy way to display Geometric Mean in a boxplot?

Isn't there a transformation you can do that will give you the geo mean? Take the log and then the average is your geo mean?
Could you add the transformed data to your graph, but make it invisible and have that mean calculated as your shown statistic?

 

 

Contributor VCM
Contributor
Posts: 22

Re: Fast/Easy way to display Geometric Mean in a boxplot?

I think the geo mean is the exp of the mean of the log, so I don't think just creating new variable = log(yvar) and then running it through the sgrender will work. (Someone correct me if I'm wrong?)


VCM
Super User
Posts: 24,026

Re: Fast/Easy way to display Geometric Mean in a boxplot?

You're probably correct, I didn't look at it much, the other suggestion is create it as a macro variable and include that value in your SGRENDER procedure as a dynamic variable. 

Respected Advisor
Posts: 3,293

Re: Fast/Easy way to display Geometric Mean in a boxplot?

[ Edited ]

Fast/easy way? I guess that depends on how you define "fast" and "easy", but I would say NO there isn't a fast/easy way to do this. 

 

You could always compute the geometric mean before your run your boxplots, and then annotate them onto the plot. You can do the calculations using the GEOMEAN or GEOMEANZ functions in a data step, or the GEOMEAN option in PROC UNIVARIATE.

--
Paige Miller
Contributor VCM
Contributor
Posts: 22

Re: Fast/Easy way to display Geometric Mean in a boxplot?

[ Edited ]

I was able to get this by suppressing the mean in the box, and adding a scatterplot statement to plot the geometric mean (which had been calculated earlier in the program):

boxplot x=xvar y=yvar /whiskerattrs=(thickness=0) display=(fill median outliers);
scatterplot x=xvar y=gmean/MARKERATTRS=(SIZE=6pt color=cx0066ff SYMBOL=trianglefilled);

Super User
Posts: 24,026

Re: Fast/Easy way to display Geometric Mean in a boxplot?

What about a TEXT statement? Instead of scatterplot?

Ask a Question
Discussion stats
  • 6 replies
  • 293 views
  • 5 likes
  • 3 in conversation