I am looking at a highly skewed variable where most values are clustered around 3-12 but values range from 0-350. When I log-transform the variable it almost fits a normal distribution. I would like to perform and log conversion and back-transformation when reporting the mean. My code is:
proc surveymeans data=work.test geomean;
var ex;
run;
When I run this code after removing all 0 values I get a number that looks like what I would expect. The problem is when I try to run it on all values of the variable, I get an error message saying 'a variable must be positive when geometric mean is requested'. Can I get around that by adding 1 to all values of the variable?
Yes, you can. See "Log transformations: How to handle zero values." Physically, you are changing the measurement definition. For example, instead of a count, you are no measuring "one more than the count."
I always encourage analysts to ask whether the LOG transformation is the best to use. For example, the square-root transformation is also a normalizing transformation but preserves the value of zero.
I am basing these methods off of a paper that says they 'performed a log conversion and report results following back-transformation'. At first I assumed that meant geometric mean but now I do not think so. Does that just mean they completed the analyses on log-tranformed variables but reported the means un-tranformed?
I do not think the geometric mean is what I should be using here after all. Adding a value to the variable dramatically changes the geometric mean. So for example adding .00001 gives me a geomean of 3.55 (SE 0.05) while adding 1 gives me a geomean of 6.13 (SE 0.04). The smaller the constant, the smaller the geomean. This would make sense since the geometric mean of x, y, z = sqrt(x*y*z). But I cannot see a way to determine what constant to add.
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.