© W.This page shows how to facilitate statistical analysis by creating new SPSS variables via recoding, i.e., remapping values from existing variables. User missing values, these will be recoded to 2 in the last example (and of course won't be defined as missing anymore). CAUTION: Assuming that 8 and 9 are still defined as Note that "lowest" can be abbreviated as "lo" and "highest" as "hi". The second command recodes all values from the value 2 to (and including) the highest value into the value 2. The first command recodes all values from the lowest value to (and including) value 3 into the value 3. Some keywords help to make this process easier. Often, several values of a variable have to be addressed. You may wish to either define 7 now as missing or to assign a value label that tells you the meaning of 7. If you have system missing values and want to recode only these to another value, you can use the keyword "sysmis" instead of "missing".Īgain, if you have defined values 8 and 9 as missing, 7 will not be recognized as a (formerly) missing value. 8 will still be defined as missing.Īll missing values (i.e., values 8 and 9 and perhaps also system missing values) will have the value 7. Here's a few examples and what they do.Īll missing values (i.e., values 8 and 9 and perhaps also system missing values) will have the value 8. Missing values can be addressed via the keywords "sysmis" or "missing".Īssume that in addition to the values 1 thru 4, there are also values 8 and 9 which are defined as missing values. However, if you wish to RECODE these variables INTO new variables, for each variable a separate RECODE command line is necessary. RECODE famimpor workimpo chldimpo (4,3=2) (ELSE=1). So don't forget to label the new variable.Ĭan be addressed in one RECODE statement, provided that all variables are to be affected in the same way, as in the following example. One problem with RECODE INTO, however, is that variable and value labels are not automatically created (how should they?). RECODE famimpor (4,3=2) (ELSE=1) INTO famimpor. You can also use it with explicit values, as in the following example:
The ELSE part of the RECODE command is not restricted to the "COPY" case just explained. Of course, you can make as many explicit recodings as you like and then deal with the rest via ELSE=COPY. This changes all occurrences of value 4 to value 3, and all other values are copied to the new variable. RECODE famimpor (4=3) (ELSE=COPY) INTO famimpon. However, all other values would be treated as system missing. This would change all occurrences of value 4 to value 3. WRONG: RECODE famimpor (4=3) INTO famimpon. If the RECODE command names only part of the values, all the other values will be treated as system missing values. In this case, you have to be sure that the new variable has all the valid values you wish it to have. Note, however, that you have to take some precautions when RECODING INTO a new variable. I use such memotechnic devices quite frequently, but of course you don't have to.) The old variable remains intact, however, and the dichotomous variable is added to the data set with the name famimpod (with "D" indicating that you have a dichotomous variable. This creates a dichotomous variable with cut-off point between 2 and 3. RECODE famimpor (1,2 =1) (3,4 = 2) INTO famimpod. Fortunately, you can create new variables with the RECODE command by adding INTO NEWVAR. You should do so only if either you can reconstruct the original values from the new ones (this would be possible only in the last example!) or if you are damn sure that you have a valid copy of your data set elsewhere. One problem is that all the above examples change the original values of the variable. Note that this can be achieved more easily with the COMPUTE command ( COMPUTE famimpor = 5 - famimpor.). (If you have value labels, perhaps you should change these now accordingly). This changes all occurrences of value 4 to value 3. RECODE var1 (1,2 = 1) (3 thru 8 = 2) (missing = 99) (else = copy)Īssume we have variable famimpor with values 1, 2, 3 and 4, measuring how important having a family is for the respondent. The new values can be stored in the same variable or in a new one. The RECODE command is used to change some or all values of a variable.