03-29-2018 11:38 AM
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:
define statgraph XXX;
...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);
proc sgrender data=mydata template = XXX;
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,
03-29-2018 11:54 AM
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?
03-29-2018 12:03 PM
03-29-2018 12:08 PM
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.
03-29-2018 12:59 PM - edited 03-29-2018 04:25 PM
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.
04-04-2018 04:19 AM - edited 04-04-2018 04:20 AM
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);