SAS Log Function: Using Log Transformation SAS
sas log function, sas natural log, log transformation in sas, log transformation sas
You might be interested in these courses:
Complete & Practical SAS
Workshop in Probability and Statistics
The sas log function allows you to perform a log transformation in sas. As much as it may seem, performing a log transformation is not difficult. With this in mind, the main thing you need to know is that a log transformation can follow an input, set or by statement.
Syntax for SAS LOG Function
First of all, the argument allows you to specify a numeric constant, variable, or expression.
Second, it must be a positive numeric constant, variable or expression. In this case, we are using a numeric constant.
Finally, an example where we use a numeric variable as the argument. In this scenario, we are taking a log of peoples weight. Weight is the numeric variable and our argument.
You could probably guess how to do a log base 10 transformation.
What Do You Do With Negative Data Values?
This is where LOG1PX function can be really helpful. Let’s look at the syntax below.
Let’s add some detail in terms of what it does for us. LOG1PX returns the log of 1 + the argument (x).
LOG1PX(x) = log(1 + x)
So, let’s understand the utility of it.
First, using LOG1PX when our x is closer to 0 will lead this function to give us a more accurate result than if we used just log(x). If you need to prove this to yourself, feel free to try it now and print out the output/results.
Second, since you can’t use negative values with log(x), the 1 + x of the LOG1PX function will allow you to do the transformation. So, this is certainly one useful way of dealing with negative values when you want to perform a transformation.
As shown above, log transformations are not difficult. Obviously, if you have any questions, please ask in the comments.
Written by Ermin
You may be interested in this article: