Can you perform a log transformation in SPSS?

Problem

Can I perform a log transformation in SPSS? I have a right-skewed distribution and would like to take a log transformation to arrive at a variable with a more symmetric (hopefully normal) distribution.

Resolving The Problem

The Compute command has a function, ln(), which takes the natural log of the argument to the function. If your right-skewed variable is X, then you can compute a new variable, XLN for example, as the natural log of X. The Compute command is available under the Transform menu. The Target Variable box is where you type the name of your new, transformed variable, such as XLN. The numeric expression box is where you type the transformation expression, ln(x). If there are cases with values of 0 for X, you will need to add a constant to X before taking the log, as the log of 0 is undefined. You can add a constant of 1 to X for the transformation, without affecting X values in the data, by using the expression ln(X+1). If there are negative values of X in the data, you will need to add a sufficiently large constant that the argument to ln() is always positive.

If you prefer to run the transformation as a syntax command, the form would be as follows:

compute xln = ln(x).

or, if there are 0s in X:

compute sln = ln(x+1).

If you wish to compute the base 10 log of X, then you can use the LG10(x) function in a similar manner. For example :

compute xlog10 = lg10(x).

will compute the base 10 log of X and store it in the variable XLOG10. To compute logarithms for other bases, see Technote 1476045. As explained in that technote, the transformation of VARX to its base 2 logarithm involves dividing the natural log of X by the natural log of the desired base, i.e., by the natural log of 2.

compute log2x = ln(x)/ln(2) .

Related Information

[{"Product":{"code":"SSLVMB","label":"IBM SPSS Statistics"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"Not Applicable","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

57723

Modified date:
16 April 2020

swg21481524