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
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?
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.
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.
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);
What about a TEXT statement? Instead of scatterplot?
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.