# SAS Data Transformation: Using Log Transformation SAS

**sas data transformation, sas log function, sas natural log, log transformation in sas, log transformation sas**

**SAS Data Transformation, Introduction**

Using SAS for data transformation is not difficult. 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. *

**LOG(argument)**

Second, it must be a *positive* numeric constant, variable or expression. In this case, we are using a numeric constant.

**xvar=log(5.0)**

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.

**xvar=log(weight)**

You could probably guess how to do a log base 10 transformation.

**xvar=log10(weight)**

##### What Do You Do With Negative Data Values?

This is where LOG1PX function can be really helpful. Let’s look at the syntax below.

**LOG1PX(x)**

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:

## No responses yet