[Skip Global Navigation]

Training

Training Home

SPSS Trainer Tip: SPSS 14.0 for Windows®

Instructor profile

Name: Nancy Morrison

About Nancy: With more than 26 years at SPSS Inc., Nancy has significant experience in consulting and training on data management, data analysis, and data mining techniques that rely on SPSS software. Currently she serves as a course developer and educator for statistical and data mining applications. In her free time, Nancy enjoys hiking in the desert near her home in Tucson, Arizona.

Creating data values from value labels in SPSS 14.0

Yes, user suggestions really do lead to enhancements in SPSS. Here is a "wish list" suggestion fulfilled in SPSS 14.0.

With the new VALUELABEL function in SPSS, you can easily create data values from value labels. In the COMPUTE dialog box, you'll find the VALUELABEL function under the "Miscellaneous" function group.

For example, the variable reason1 has the following value labels:

Value Labels for reason1
Figure 1: Value labels for “reason1”

The Compute dialog shown below creates a new string variable, reason1_label, containing the value labels from the variable reason as data values. Since the new variable is a string variable, you must specify the Type as "string" and the width of the string variable. In Figure 2 below, the specified width is 20 characters because the longest value label for reason1 is 20 characters. If you don't know the width of the labels, specify a width of 120 characters—the maximum width for value labels.

Using the VALUELABEL function in Compute Variable
Figure 2: Using the VALUELABEL function in Compute Variable
Click to enlarge.

Using the split view in the SPSS Data Editor, you can see the results of the VALUELABEL function.

Results of VALUELABEL function
Figure 3: Results of VALUELABEL function

You can easily perform this function on several variables by using SPSS syntax and the DO REPEAT structure, such as:

ppppDO REPEAT varlist=reason1 TO reason3
ppppppppp/newvars=reason1_label, reason2_label, reason3_label.
pppp- STRING newvars(A20).
ppp - COMPUTE newvars=VALUELABEL(varlist).
pppp END REPEAT.

This syntax creates three new variables: reason1_label, reason2_label, and reason3_label from the value labels of reason1, reason2, and reason3. The DO REPEAT structure repeats the STRING and COMPUTE commands three times, substituting the variables from the varlist and newvars lists in each iteration. If you are unfamiliar with the DO REPEAT – END REPEAT structure, search the SPSS Help Topics for additional information and examples.

Now it’s easy to convert value labels to data values, whether you need to do it for one variable or your entire file!

We offer SPSS courses at locations around the world.
Find a course in the location nearest to you.