Desktop User Guides > Reporter > Using variables > Creating new variables > Creating variables: Examples
Creating variables: Examples
This topic shows you some examples of how to create new variables using the New Variable dialog. Some of these examples can also be achieved by other methods, for example, using the Copy or Merge options.
Copying an existing variable
To make a copy of another variable, type the name of the variable you want to copy in the box. For example, if you want the new variable to be a copy of the age variable, type:
in the New variable syntax box.
Ensure that the new variable has the same data type as the variable you are copying (when you use the Copy option on the Variables menu, the new categorical variable has the same categories as the variable you are copying).
Merging categorical variables
To merge two or more categorical variables, type the names of the variables you want to merge separated by the + operator.
For example, to create a total awareness variable from variables called Favorite, Spontaneous, and Prompted, type:
Favorite + Spontaneous + Prompted
in the New variable syntax box.
The new categorical variable has the same categories as the variables you are combining. If the same category appears in more than one of the variables, it appears only once in the new variable.
Numeric variables
To create a new numeric variable and base it on a formula that uses one or more existing numeric variables, type the formula into the box using the names of the existing variables.
For example, in the Museum sample the visits and visits12 variables are both numeric; create a new numeric variable based on the following expression:
visits12 / visits * 100
Boolean variables
To create a new Boolean variable for use as a filter, enter the expression for the variable.
For example, the following expression selects respondents who are male:
Gender = {Male}
Text variables
Sometimes you might want to concatenate two or more text variables, but separate the text in the variables using a specific character.
The following expression concatenates the name and address variables and separates the text with a colon and a space:
name + ": " + address
See also
Creating new variables