Creating a new variable containing a single code
A single code variable is constructed by selecting individual codes from existing variables and combining them to form a new, complex code. The process involves:
Selecting the variables that contain the codes you wish to use;
Selecting the appropriate codes from those variables, and
Defining how those codes are to be combined to create the new variable.
This is all done within the single code variable construction dialogue box.
Define the new variable
To define the new variable identify the codes that will make up the new variable and how they will be combined.
For example you may wish to create a variable that captures all those respondents in either of two age groups, but which excludes those who are self-employed.
Open the single code variable construction dialogue box
Click on the single code construction icon on the tool bar
Select Variables|Create new variables |…..Containing a Single code
Or use the short cut key: Ctrl + S
The variable construction window
The window used for constructing single code variables has four main areas:
Variable titles list
This displays the index of all the variables in the project database, including any user-defined variables
This displays the codes of any variable that has been selected and from which the new variable will be constructed.
This is used to define the way in which the codes of any one variable will be combined to form the new variable.
This displays the definition of the new code and any name you have assigned to it.
Create the variable
From the Variable titles area, select the first of the variables that contains codes that you wish to use in the construction of the new variable. The codes of this variable will now appear in the Variable codes area.
Select the codes that you wish to work with by highlighting them in the Variable codes area. To select more than one code at a time hold the Ctrl key down as you select them. To select a range, click the first code then holding the Shift key down, select the last.
To add the selected code to the list of conditions that define a particular sub-set, click on the AND button to the right of the Variable codes area
To exclude the selected codes in the definition of the new variable, click on the NOT button to the right of the Variable codes area
The conditions created will be reflected in the Conditions created area. All conditions in the list must be satisfied.
Select the next variable that contains codes that you wish to use to filter the new variable and continue as above.
When you are satisfied that the Conditions created area correctly defines the first group you are interested in, click on the Add button to the right of this area. The definition will now appear in the New code area.
Repeat the above for other sub-sets that you wish to add.
If you make a mistake while constructing your codes, use the Clear button to the right of the Conditions created area to start again.
If you have added a code to the New Variable list and then changed your mind, use the Delete button to the right.
Enter a title for the new variable by selecting (Title) in the uppermost box of the New code area and entering a title.
If you are satisfied with the definition and the title of the new variable, click on the Write code button in the top right hand corner of the screen.
The new code will now be written and added to the project file. The new variable will appear in the variable index at the bottom of the index in a new folder titled User-defined variables.
Having created the variable you may wish to edit the names of the codes to produce more user-friendly alternatives. This can be done by running a table using the variable and editing the labels by double-clicking on them.
See also: Deleting variables, Creating Variables, Logical Operators, and Editing text elements