SPSS Syntax Files

SPSS Syntax Files

We need to create composite variables that include our individual variables to create scales. Before we do this part, we need to recode any reverse-scored items to make sure that all items in the composite variables are coded in the same direction. Next, we need to compute the new, composite variables. Finally, it is good to compute the mean and standard deviation for newly-created composite variables.

Syntax files, recoding variables, compute statements, out files, and the computation of variables in SPSS.

A. Opening the file

1. The Jealousy data set can be found here in .sav format.
2. It can be opened with SPSS.

B. Recoding Variables

When we have multiple items in a psychological measure, several items are often worded in the opposite direction. To take this fact into account when we score our variables, we need to ‘recode’ such items to make them in line with the other items. The best way to do this recoding is to use a SYNTAX (.sps) file.

Attached to this document are the commands for a syntax file I made to recode the ‘reverse-scored’ items that exist in the jealousy data:

To reproduce this file in SPSS, click on File, then New, then Syntax. A blank page will appear. Type in the commands from the attached example. In a syntax file, you use an asterisk (*) to indicate a comment to yourself (not something read by the computer). Save this file when you are done typing the recode statements.

To recode variables, simply highlight the commands you want to execute – then go to the ‘run’ command and click ‘selection.’

C. Computing new variables

After you have recoded all reverse-scored items, you need to compute the composite variables. Create a new syntax file OR add to your existing syntax file. See attached example that works for this data set. Note how the syntax for creating these compute statements works.

After you type all these commands in (it will be good for you), run the compute statements. After you have done this part, notice that you now have newly created variables in your data file. These variables are your composite variables.

D. Output files. To get a sense of completing one simple SPSS command that produces an outfile, choose any of the composite variables you created. When in the Data file, click ‘analyze,’ then ‘descriptive statistics,’ then ‘Descriptives.’ Now choose the variable you want to examine.’ The Descriptives command will give you the mean, standard deviation, N, and range of the variable of interest.’ After you choose your variable, either hit ‘paste’ (not OK).’ After you hit ‘paste,’this command will go into an existing syntax file (at the bottom).’ You can then run the command from this syntax file by highlighting it and clicking ‘run’ then ‘selection.’

To be handed in:

A. A soft copy (e.g., emailed copy of disk) including the following files:
1. The modified data file (.sav) (with the composite variables computed)
2. Syntax file(s) (.sps) with recode, compute, and Descriptives commands.
3. An Output file (.spo) with results from the descriptives command.

________________________________________________________

* Recoding items for the jealousy data —

* recoding the reverse-scored items from the mood scale across times A, B, and C

RECODE
mood_a1 mood_a7 mood_a12 mood_a17 mood_a21 mood_a24
mood_b1 mood_b7 mood_b12 mood_b17 mood_b21 mood_b24
mood_c1 mood_c7 mood_c12 mood_c17 mood_c21 mood_c24
(1=5) (2=4) (3=3) (4=2) (5=1).
EXECUTE.
Compute statements for jealousy data

______________________________________________________

* Computing variables for the jealousy data.

* Computing composite variables for Mood Scales (higher scores mean more psychological discomfort)
* Computing moodtot1

Compute moodtot1 = sum(mood_a1, mood_a2, mood_a3, mood_a4, mood_a5, mood_a6, mood_a7, mood_a8, mood_a9, mood_a10, mood_a11, mood_a12, mood_a13, mood_a14, mood_a15, mood_a16, mood_a17, mood_a18, mood_a19, mood_a20, mood_a21, mood_a22, mood_a23, mood_a24) .
Execute.

* Computing moodtot2

Compute moodtot2 = sum(mood_b1, mood_b2, mood_b3, mood_b4, mood_b5, mood_b6, mood_b7, mood_b8, mood_b9, mood_b10, mood_b11, mood_b12, mood_b13, mood_b14, mood_b15, mood_b16, mood_b17, mood_b18, mood_b19, mood_b20, mood_b21, mood_b22, mood_b23, mood_b24) .
Execute.

* Computing moodtot3

Compute moodtot3 = sum(mood_c1, mood_c2, mood_c3, mood_c4, mood_c5, mood_c6, mood_c7, mood_c8, mood_c9, mood_c10, mood_c11, mood_c12, mood_c13, mood_c14, mood_c15, mood_c16, mood_c17, mood_c18, mood_c19, mood_c20, mood_c21, mood_c22, mood_c23, mood_c24) .
Execute.