This article describes how to use Displayr to replicate the standard SPSS functions of Transform > Recode into Same Variables and Transform > Recode into Different Variables.
This includes:
Requirements
- Familiarity with the Structure and Value Attributes of Variable Sets.
- A data set loaded into a Displayr document.
Method - Modifying existing variables
The methods described in this section will modify the existing variable and all of the outputs that use it. If you are interested in recoding into a new variable see Method - Creating new variables below.
Recoding into the same variable to compute a mean
If the structure of the variable is Numeric or Numeric - Multi, Displayr will automatically compute an average. If the structure is Nominal, Nominal - Multi, Ordinal, or Ordinal - Multi, you will need to follow these steps:
- Select the variable in the Data Sources tree.
- From the object inspector, go to Data > Properties > Structure and update to Numeric (or Numeric - Multi if the structure is Nominal - Multi or Ordinal - Multi).
- Click Properties > Values.
- In the Value column, enter the desired values and click OK. For instance, you might want to do this if you need to reverse the scales of a rating question or enter a mid-point value for age.
- OPTIONAL: You can also copy and paste using the Export and Import buttons.
- Click OK.
Merging categories to compute a percentage
- Drag the variable from the Data Sources tree onto the Page.
- Select the category(ies) in the table you want to merge, select the 6 dots icon and drag the category onto another category.
Merging categories does not change the original values of the variable. Merging categories and their values are completely independent. However, this will change the same categories in other tables and outputs, i.e., it will universally update the categories, as seen below. If you prefer this not to happen, you will first need to duplicate the variable (via right-click Duplicate) and then perform the merge in the new variable.
You can easily revert to the original categories by right-clicking the merged category and selecting Split.
Adding a new category
You might want to retain the original categories, but also add a new Top K Box (or Bottom K Box) to a variable. You can do that by:
- Select the variable set(s) in the Data Sources tree. If you have more than one variable set selected, a new category will be added to each.
- Go to Anything > Data > Variables > Modify > Add Categories > Add Top K Category NETS (Top K Boxes) or Add Bottom K Category NETS (Bottom K Boxes).
- Enter the number of categories you want to include, such as "2" for a top 2 box.
- Enter a label for the new category.
- Click OK.
Note that this method adds the new category only to tables that use the variable set. The new category will not be present in the value attributes of the variable set.
The special case of binary variables
Survey data often contains sets of categorical variables that need to be recoded into binary variables. For example, with the six variables shown in the table below, it is common to recode this data to take a value of 1 if a person has selected Like or Love and 0 otherwise (i.e., a "Top 2 Box" score).
In Displayr, this is done by:
- Select the variable set in the Data Sources tree.
- From the object inspector, update Data > Properties > Structure to Binary Multi: Non-Mutually Exclusive Categories.
- Press the Fix button that will appear above the object inspector. Ensure that the appropriate choices have been selected in the Count this Value column (e.g., Like and Love).
- Press OK.
Method - Creating new recoded variables
There are multiple methods you can use to recode into new variables, such as:
- How to Create Top Two Category Variable(s) (Top 2 Boxes)
- How to Create Bottom Two Category Variable(s) (Bottom 2 Boxes)
- How to Create Top Three Category Variable(s) (Top 3 Boxes)
- How to Create Bottom Three Category Variable(s) (Bottom 3 Boxes)
- How to Recode Net Promoter Score (NPS) Variable(s)
- How to Create Numeric Variable(s) from Code/Category Midpoints
The full list of automated scripts can be found at Automatic Functions to Create New Variables.
You can select multiple variables at once and run these scripts to create new variables with the recoded values and data.
Next
How to Recode Variables Using Category Midpoints
How to Recode Net Promoter Score (NPS) Variable(s)
How to Create Top Two Category Variable(s) (Top 2 Boxes)
How to Create Top Three Category Variable(s) (Top 3 Boxes)
How to Create Top K Category Variable(s) (Top K Boxes)
How to Create Bottom Two Category Variable(s) (Bottom 2 Boxes)
How to Create Bottom Three Category Variable(s) (Bottom 3 Boxes)
How to Create Bottom K Category Variable(s) (Bottom K Boxes)
How to Recode Low Values (Capping) in Numeric Variables
How to Recode High Values (Capping) in Numeric Variables
How to Create Numeric Variable(s) from Code/Category Midpoints