This topic shows you some examples of how to create new variables using the New Variable dialog box. Some of these examples can also be achieved by other methods, for example, using the Copy or Merge options.
To make a copy of another variable, simply type the name of the variable you want to copy in the text box. For example, if you want the new variable to be a copy of the age variable, type:
age
into the New variable syntax text box. When making a copy of another variable, 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 will automatically have the same categories as the variable you are copying).
To merge two or more categorical variables, enter the names of the variables you want to merge separated by the + operator. For example, if you want to create a total awareness variable from variables called Favorite, Spontaneous, and Prompted, type:
Favorite + Spontaneous + Prompted
into the New variable syntax text box. The new categorical variable will automatically have the same categories as the variables you are combining. If the same category appears in more than one of the variables, it will only appear once in the new variable.
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 text box using the names of the existing variables. For example, in the Museum sample the visits and visits12 variables are both numeric. You could create a new numeric variable based on the following expression:
visits12 / visits * 100
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}
Sometimes you may 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