I hope you’re getting started using SPSS Syntax by hitting that Paste button when you use the menus.
But there are a few parts of SPSS you can’t do that with. Specifically, there are syntax commands for doing all the variable definitions that you usually fill out in the “Variable View” window. But there are no Paste buttons there, so you have to know how to write the syntax from scratch.
I find the three variable definitions that I use the most are defining Variable Labels, Value Labels and Missing Data codes. The syntax is simple and logical for all three, so I’m going to just give you the basic code, which you can keep on hand and edit as you need.
For a data set with the variables Gender, Smoke, and Exercise, with the following definitions:
Gender: 0=Male, 1=Female
Smoke: 1=Never 2=Sometimes 3=Daily
Exercise: 1=Never 2=Sometimes 3=Daily
For all three variables, 999 = a user-defined missing value
We could use the following code to give descriptive variable labels, encode the value labels, and define the missing data:
VARIABLE LABELS
GENDER ‘Participant Gender’
SMOKE ‘Does Participant ever Smoke Cigarettes?’
EXERCISE ‘How Often Does Participant Exercise for a30 Minute Period?’.
Notice two things:
1. I could put all three Variable labels in the same Variable Label statement
2. There is a period at the end of the statement. This is required.
VALUE LABELS
GENDER 0 ‘Male’ 1 ‘Female
/SMOKE EXERCISE
1 ‘Never’
2 ‘Sometimes’
3 ‘Daily’.
MISSING VALUES
GENDER SMOKE EXERCISE (999).
Since all three variables have the same missing data code, I could include them all in the same statement.
There are, of course syntax rules for all of these commands, but you can easily look them up in the Command Syntax Manual.
Want to learn more? If you’re just getting started with data analysis in SPSS, or would like a thorough refresher, please join us in our online workshop Introduction to Data Analysis in SPSS.
Leave a Reply