COM317 800 1 ■ BASIC TRANSFORMATIONS: COMPUTE Often in the process of data analysis it is necessary to change the values of one or more variables or create new variables from existing variables (referred to as "transformations"). COMPUTE is the procedure used to create new variables from existing variables. The new variable can then be used in various statistical procedures. ● Example of arithmetic expression sum: Total = Score1+Score2+Score3 average: Total = (Score1+Score2+Score3)/3 ● Executing the COMPUTE Command After typing in the Target Variable name and either typing in or pasting in the components of the Numeric Expression, you simply click on OK to complete the creation of the Target Variable. [The user can also click on Paste in the COMPUTE Dialog Box to insert the COMPUTE command into a Syntax Window. This should be done before clicking on OK.] SPSSWIN then executes the COMPUTE command. For every case in the file a value is calculated for the new variable. The target variable (in the above example, "Spend") then appears in the column directly to the right of what had been previously the last column in the data file. The user is encouraged to label the variable and values of the newly-computed variable. If, for a particular case, a value cannot be computed for a new variable, a period ( . ) will appear in the cell for that case. A value would not be computed, for instance, if the case has a Missing Value for one or more of the existing variables used in the COMPUTE. Normally you would save the data file with the additional computed variable(s). The newly-computed variables would be available to use in statistical procedures. ● Example using data file 1. Calculate the total number of hours per week spent watching television (v12) and using the Internet (v13). 2. The age of respondent (v25) COM317 800 2 ■ BASIC TRANSFORMATIONS: RECODE The RECODE command allows the user to change the values assigned to an existing variable. It is speedy, accurate and consistent means for applying new values to variables. 1. RECODE INTO SAME VARIABLES If you RECODE into the SAME variable(s), this means that the new values you will assign for the variable(s) will overwrite the existing (original) values. If you save the file with this recode intact, you permanently lose the original values for the variable(s). Recommendation: Do NOT recode into the same variable. 2. RECODE INTO DIFFERENT VARIABLES If you RECODE into DIFFERENT variable(s), this means that you create new variables which take the new values you assign. If you save the file with the recode intact, you save the new variables along with previously existing ones. 3. Opening the RECODE Dialog Box for RECODE INTO DIFFERENT VARIABLES ***Click on TRANSFORM RECODE RECODE INTO DIFFERENT VARIABLES 4. Uses of RECODE 1) To use a continuous variable in a crosstabulation (here is an opportunity for you to use SPSSWIN's Help facility to learn what is meant by the term "crosstabulation") it is necessary to collapse the variable’s values into a set of discreet categories. Ex) Collapse hours of watching TV(v12) & hours of using internet(v13) into a three category 1. 0~5 : Low 2. 6~15 : Medium 3. more than 16 : High 2) In scale construction it may be necessary to change the values of a variable. For example, in a set of questionnaires items, you might need to "reverse" the coding of some items so that a low value on all items has the same conceptual meaning (e.g., "negative"). Typically, our goal is to create a total score based upon a sum of scores from individual items. We use reverse coding so that, for instance, a higher value will represent a more positive attitude for each of a series of statements. COM317 800 3 Ex) Construct new scale on the political orientation using v5 through v11. Make low score value a positive prospect for Liberal perspective, then COMPUTE it and make new variable. ► Recode v8 into a different variable 1 5, 24, 42, 51 ■ SELECTING CASES The SELECT CASES procedure is used to limit an analysis to only a specified subset of cases. The subset is chosen on the basis of some criterion. For instance, if you have data from a set of questionnaires filled out by freshmen, sophomores, juniors and seniors, you can "select" only respondents who are seniors To SELECT a subset of cases 1. 2. 3. From the DATA Menu click on SELECT CASES The SELECT CASES Dialog Box will appear. Click on the “If condition is satisfied” radio button. Then click on the IF pushbutton. The SELECT CASES: IF Dialog Box will appear. You will notice its similarity to the COMPUTE Dialog Box. You build a conditional statement in the same fashion as was done for IF CASES. Click on a variable from the Variable list that you wish to use as a criterion. Then press the (>) arrow button. The variable name appears in the conditional expression “box”. Then, using the calculator pad, complete the expression. 4. Some conditional expressions might include: V1 = 1 V1 <= 2 & V5 = 2 V1 >= 3 & V1 <= 5 V22 = 1 | V22 = 9 Ex) the opinion of women right to abortion in case he or she is liberal COM317 800 ■ CONDITIONAL EXPRESSION: IF CASES The IF command, like the COMPUTE command, is used to create new variables. However, IF offers an additional feature: The user can create different subgroups of a new variable using one or more existing variables. Cases are assigned to a specific subgroup if conditions (specified by the user) are met. ● Example using data file Q1: The relationship between “political stance (v3)” & “women’s right to abortion(v5)” 1. Political stance (v3) 2. Women’s right to abortion (v5) 1) 2) 3) 4) Liberals who think women should have a right to abortion Liberals who think women should not have a right to abortion Conservatives who think women should have a right to abortion Conservatives who think women should not have a right to abortion *** Arithmetic formula 1) (v3=1 or v3=2) & (v5=1 or v5=2) 2) (v3=1 or v3=2) & (v5=4 or v5=5) 3) (v3=4 or v3=5) & (v5=1 or v5=2) 4) (v3=4 or v3=5) & (v5=4 or v5=5) Q2: The relationship between “sex (v22)” & “gun control (v6)” 2. Sex (v22) 3. Gun control (v6) 1) 2) 3) 4) Male who agrees gun control Male who disagrees gun control Female who agrees gun control Female who disagrees gun control *** Arithmetic formula 1) (v22=1) & (v6=1 or v6=2) 2) (v22=1) & (v6=4 or v6=5) 3) (v22=2) & (v6=1 or v6=2) 4) (v22=2) & (v6=4 or v6=5) 4