Have you ever wondered what that little “Paste” button next to the “OK” button in SPSS does? It automatically sends the syntax (code) for the analysis you just created to the SPSS syntax editor! The syntax editor is a helpful tool that can allow you to more fully specify your analyses, create notes surrounding your analyses, and repeat what you have already done quickly and easily. In the syntax editor, you basically create (or edit) little bits of code normally used by SPSS in the background. But do not get intimidated! SPSS syntax is pretty easy to use, and you can produce templates for analyses wherever you see the “Paste” button.
Aligning theoretical framework, gathering articles, synthesizing gaps, articulating a clear methodology and data plan, and writing about the theoretical and practical implications of your research are part of our comprehensive dissertation editing services.
If you want to write syntax from scratch, you can go to the File dropdown in SPSS and select New à Syntax. This will give you a blank syntax window. This is a good place to start if you need to compute some composite scores (variables). What kind of composite score you create is dependent on your measure. Instructions for scoring can usually be found either with the instrument itself, manual for the instrument, or the development article for the instrument.
In the picture below, there are two methods shown to calculate a mean score, and two methods to calculate a sum score. First, you type your starting command. In this case, the command is COMPUTE, because we want to compute a new variable. Then, after a space, type your new variable name and an equals sign, then write your command out.
I tend to use the MEAN command rather than typing out the actual calculation to average (as seen in Score2 in the picture), as the MEAN command will work with missing data. Otherwise, SPSS will not return a value for any case that is missing data. However, if you have too much missing data, taking the mean could be misleading.
Take specific note of the commas and spacing—if there is an issue with commas, spacing, periods, or any other little nit-picky thing, your syntax will not work! After you have typed out your command, you will want to click and drag to highlight the portion of syntax you want to run. For the computation of new variables, you will always want to make sure you include the EXECUTE command in the syntax, as otherwise your variable will not show up in your dataset.
Once you’ve clicked and highlighted the appropriate portions of syntax, you will either hit CTRL R on your keyboard (for Windows users), or click the green arrow in the tool bar, which is circled in the picture above. You will know you have done it right when an error does not come up and the new variable appears in your dataset. You will also get information in your output window.
If you prefer to design your analyses using the SPSS “point and click” interface, follow these steps. First, set up your analysis as usual. For this example, we will do a regression. Select all your appropriate variables and options for the regression, but instead of clicking OK like usual, click Paste (see circled button in the picture below). This will generate the syntax for that same analysis automatically. SPSS will send it to the active syntax window (if you have multiple up), or if you have no syntax window up, it will open a new one for you.