What is the simplest way to recode values of a variable (e.g., split a continuous variable into categories)?

Recoding functions of practically unlimited complexity can be custom-defined in Statistica Visual Basic and used repeatedly in your data transformation programs.

However, a quick on-line recoding facility can also be accessed directly from the spreadsheet at any point. Select Recode from the Data menu to display the Recode Values dialog. You can scroll the Recode Values dialog to define new values (text or numeric) of the current variable (see the groups New Value 1, New Value 2, New Value 3) depending on the specific conditions, that you define (see the Category 1, Category 2, Category 3, groups below).

For example, the recoding conditions specified above would translate the values less than or equal to 3 of the current variable (Quality) into Low, the values greater than 3 and less than or equal to 6 into Medium, and the values greater than 6 and less than or equal to 10 into High. Note that any other values that occur in the Quality variable would be translated into the missing data code because the MD Code option button is selected in the Other group. Note also that Statistica first finds all cases that meet Category 1 and recodes them; then Statistica only searches through the remaining cases that have not been recoded to see if they meet Category 2. Hence, you do not have to specify Quality > 3 AND Quality <= 6 as Category 2.

When specifying the conditions, follow the standard syntax conventions that are common in Statistica to all those procedures that involve any operation of selecting cases based on their values (see What syntax can be used to create case selection/verification/recode conditions?). You can also save the current verification condition to a text file or open a file with previously saved conditions.

Note: Recoding conditions can be much more complex, and they can be defined such that the new values of the current variable do not depend on the old values of that variable, but only on values of some other variables in the datafile. Thus, this facility can be used not only to recode existing data, but also to create values of a new variable based on conditions met by other variables (as illustrated in How do I create values of a new variable based on conditions met by other variables?).