Recoding rules are the definition of the logic to do your recoding.


image


To create a recoding rule, click the Recode option for the desired variable. This will open the recoding window. 



The recoding window looks slightly different depending on what type of variable is being recoded. In general, one or more values (Old values) are selected, and then the value is recoded (New value). You can also add a filter based on one variable to the recoding rule.


A variable can have unlimited recoding rules. If a variable has multiple rules that are overlapping each other, then only the latest one will be valid and applied to the data. The non-valid rules are marked in red, as shown in the example above. The image above shows a variable with four recoding rules. As the first and last rules are overlapping each other, the first one becomes invalid and will not be applied to the data.


If data needs to be recoded into a new variable, then the existing compute variable function can be used instead. Data also cannot be recoded into a grouped answer. If needed, simply update the grouped answer definition instead.


Note: system missings can be recoded into something. A system missing has no value and is called 'Null' in the system, so then checkbox need to be ticked. The same is valid for recoding something into system missing. 


To recode data permanently, tick the option “Recode data permanently” when setting up the recoding rule (see image below). The data will then be changed irrevocably during the next data activations which means that it is not possible to get the original data back so the feature must be used with caution. Here we see the new option to recode data permanently.



Note: data recoding rules will be applied every time the data gets activated. This can become problematic once you have a scheduled import and you use new and old values in the same rule. Example: 

  • value 10 (old value) needs to become 9 (new value)
  • value 9 needs to become 8
  • value 8 needs to become 7
  • value 7 needs to become 6

The first time data activation gets applied, the data gets recoded correctly and you won't have any 10 in your data. The second data activation, this code will run again and all 9 data will be 8. So you won't have any 9 nor 10 in your data. To solve this issue, you can:

Use new values to recode it into, so these should be unique from the old value, see example below

  • value 10 (old value) needs to become 90 (new value)
  • value 9 needs to become 80
  • value 8 needs to become 70
  • value 7 needs to become 60

Or you could do a permanent recode and remove the rule after data activation.