How to Create a Variable with Standardized Values
Jump to navigation
Jump to search
Sometimes it is necessary to transform the values of a variable so that the mean of the data is 0 and the standard deviation is 1. Such a variable is normalized or standardized. This is achieved as follows:
- If the variable you wish to transform is not a already numeric (i.e., with a Structure of Numeric, Numeric - Multi, or Numeric - Grid), you need to first change its structure and check that the values in the Value Attributes are correct. If you do not wish to change the structure, because you are using it elsewhere, first duplicate the variable by selecting it and pressing Home > Duplicate.
- Insert > R (Variables) > Numeric.
- Enter the R CODE as scale(Q12r2, center = TRUE, scale = TRUE), where you replace Q12r2 with your variable name. The easiest way to do this is to drag the variable from Data Sets into the R CODE box.
- Press Calculate.