|
|
|
Transforming Data
In this section...
Compute
Recode
There may be times when you want to make adjustments to your data set or to a variable in order to better understand it, to better manage it, or to better answer your research question(s). SPSS allows you to add, subtract, multiply or divide variables of interest, and thereby create a new variable out of existing data. In doing so you will not in any way be changing the raw data; rather, you are only modifying how it is presented. For example, you could compute (create) a new variable called "achievement" that combines subjects' individual math, science, and reading scores. To do this you use the Compute function. As the name suggests, Compute allows you to create (compute) new variables or values using existing data. The newly-created variable does not replace an existing one, but is automatically placed at the end of the data set.
Another useful function in SPSS is Recode. Say for instance you realize during data analysis that the scale you devised to collect data uses "0" to indicate large amounts of the variable and "10" to indicate small amounts. The Recode function allows you to correct this counterintuitive scaling. (This particular process is generally known as "reverse coding.") Using this function you can "reassign" the data so that "0" indicates a small amount and "10" a large amount of the variable of interest. No need to develop a new instrument and collect data again!
Compute and Recode are powerful tools to help you to manage and understand your data.
Compute
| Reminder to all users: it is strongly recommended to have an SPSS data set open and running while working through these sections. |
Transform --> Compute
| Note: Sequences of command such as the one above will be presented in abbreviated form. Transform --> Compute means to access the Transform menu and select Compute from among the options presented. |
To illustrate this extremely useful function, let's assume you have collected achievement scores for 100 high school seniors of both genders. On each participant you have scores for math, science, reading comprehension, verbal ability, quantitative reasoning, and writing. Your research question asks, in part, if there is a difference between boys and girls in quantitative reasoning skills. One way to answer this question would be to run a statistical test on boys' and girls' scores in math and compare them; and then run the same test on the boys' and girls' scores in science and compare them; and so on. Or, you could create a new variable consisting of the average of all scores that include quantitative reasoning skills and then run a single test to examine differences bewteen boys and girls. Compute allows you to do just that.
Access the Compute function: Transform --> Compute. A dialog box appears on the screen. The cursor is in the "Target Variable" field in the upper lefthand corner. Enter here a meaningfully-abbreviated name of the new variable you wish to create; this will become the column header in Data View. (Remember, versions released before 12.0 limit variable names to 8 characters.) In the above example, the new variable encompassing all scores on a quantitative reasoning measure might be called "quant". (If you wish, you can click on the "type and label" button immediately below the "Target Variable" box and enter the requested information. If you have worked through this module sequentially, this will look familiar to you.) Think now of your own data set: which variables might you wish to combine or otherwise redefine?
| Go now to SPSS and name your new variable. |
Below the "type and label" button you will see a complete list of variables from your data set. From this list determine the variables you wish to combine or otherwise adjust and move the first variable to the "Numeric expression" box in the upper righthand corner. To do this, highlight the variable and click on the directional arrow button. Next, use the simulated keyboard below the box to select and move the mathematical function you desire. To move a function simply click on the button representing it. (You could also use the computer keyboard and simply key in the function.) Then move the second variable from the list to the "Numeric expression" box, and again chose and move the mathematical function you desire. In our fictitious study on high school achievement, "quant" (the new variable) would be described in the "numeric expression" box as "math + science + quantitative reasoning." Since "quant" is an average score of these three subvariables, however, there is an additional step: the total must be divided by three. Using the keyboard below the "numeric expression" box (or the computer keyboard) the three variables are enclosed in parentheses and the entire value divided by 3: (math + science + quantitative reasoning)/3. This string tells SPSS to add the math, science, and quantitative reasoning score for each subject and divide each subject's total by 3. The final step in the process is to click OK.
| Go now to your data set and try this. |
| Alternatively, you could use the list of functions below the "numeric expression" box to perform many mathematical calculations for you. The list contains the most common mathematical functions, as well as many statistical ones. In this example, "quant" would be defined as "MEAN" (math, science, quantiative reasoning). |
Notice what happened: the new variable (in our example,"quant") appeared in Data View after the last variable in the original data set. The cell values of the new variable also appear, and were calculated and displayed according to the rules determined by you, the researcher. Reminder: At this stage it's wise to go to Variable View and input the important descriptive information on the new variable.
Compute is an extremely important function. You will use it often. If you have not been following along in SPSS while reading this section, it is strongly recommended you do so now. Create at least two new variables from your own data set.
Recode
Transform --> Recode
The following scenario will be used to illustrate the Recode function: in a study of high school seniors, each subject was asked to rate their quantitative reasoning ability on a 10-point scale. A "1" indicated that the student perceived his or her quantitative reasoning skills to be very strong; a "10" indicated they were perceived to be very weak. You want to change this scale so that a "1" indicates perceived low quantitative reasoning skills and a "10" indicates a high level of these skills. (Tip: when designing scales it's good practice to have high scores represent large amounts of the variable and low scores represent small amounts.)
Execute the above command string. When accessing the Recode function you will see that you are immediately presented with a choice: should the recoded variable replace the existing one or should a new, stand alone variable be created? Personal preference and research experience may dictate the answer to this question. More advanced researchers may elect to replace an existing variable, especially when attempting to correct a data collection or minor instrumentation error. Novice researchers (and SPSS users) are advised to create new variables until such time that they are comfortable with this function and their ability to use it properly.
Transform --> Recode --> Into different variables
From the complete list of variables on the left, chose the variable to be recoded and move it to the "Numeric variable --> Output variable" box on the right. What appears there looks something like this: "variable name --> ?". As you can guess, SPSS is asking you to name the new (recoded) variable. Position the cursor in the Output Variable box and enter the name. The name of the recoded variable should be sufficiently different from that of the original so they will not be mistakenly interchanged, but sufficiently similar to it so as not to cause confusion. In our fictitious example, the original variable might have been labelled "QR_score" (and defined in Variable View as "score on quantitative skills survey") and could be meaningfully recoded as "QR2_score" (and defined accordingly in Variable View). Click the Change button to the right, and notice that the name of the recoded variables appears in the "Numeric variable --> Output variable" box.
| If you haven't been working with your own data set up until this point, you are encouraged to go to it now and complete these steps. |
Click on the "Old and New Values" button in the lower half of the dialog box. As the name suggests, this is where you assign new values to existing ones. It is where, in our fictitious example, the old "1" (indicating a large quantity of the variable) becomes the new "10" (indicating the same thing in a more intuitive way). In the dialog box the cursor is in the "Old Value" field. Enter here the value you wish to change. Next, hit the tab key twice and enter the value you wish to have in its place. Click on the "Add" button and you will see your proposed change appear in the "Old --> New" box. In our example of high school seniors, this first step would look like "1 --> 10," indicating that all former "1" values should be changed to "10" values. If in your data set you have only two such changes to make, you're lucky. In our example, the recoding process would need to be repeated 9 times. First, "2 --> 9" and then "3 --> 8" and then "4 --> 7" and so on.
| Go now to SPSS and enter your list of old and new values for at least one variable. |
Click on the Continue button. This takes you back to the first Recode dialog box. Click on OK. Notice that the recoded variable appears at the end of the data set. Since you created a new variable rather than replaced an old one, do some spotchecking to make certain the new values are as you intended. If not, delete the variable and try again!
|
|
|