Blog › Guide
How to enter questionnaire data into SPSS: Variable View, coding and a sample codebook
To enter questionnaire data into SPSS, work in five steps. Write a codebook that gives every question a short variable name and a number for every answer. Set up each variable in Variable View: its name, type, label, value labels, missing values and measurement level. Enter the data in Data View, one row per respondent and one column per variable, or import it from Excel, Google Forms or a CSV file. Check the data with Frequencies and Descriptives to catch typing errors. Then save it as an SPSS .sav file, which keeps all your labels and codes.
This guide walks through each step, with SPSS menu paths checked against IBM’s documentation, and ends with an illustrative codebook you can adapt. It is for students, researchers and organisations who have collected questionnaires and need a clean dataset to analyse.
Before you open SPSS: write a codebook
A codebook is a table that says how each question will be stored in SPSS: the variable name, the question wording, the code for each answer, the codes for missing answers and the measurement level. Writing it first means you make each coding decision once and apply it the same way to every questionnaire. Keep it with your data. A supervisor or analyst will need it to understand the file, and it makes the data section of your methodology chapter easier to write.
How SPSS organises questionnaire data
The SPSS Data Editor has two tabs. In Data View, each row is one respondent and each column is one variable (usually one question). In Variable View, each row is a variable and each column is an attribute of it, such as its name, label and codes. The golden rule: one row per respondent, and never more than one answer in a cell.
Step 1: Set up your variables in Variable View
Click the Variable View tab and type one variable per row. IBM notes that these attributes are saved with the data file, so you only set them once.
| Column | What it controls | What to enter for questionnaire data |
|---|---|---|
| Name | The short variable name | A unique name that starts with a letter and has no spaces, such as q1, age or sat_3. Names can be up to 64 bytes long. |
| Type | The data type | Numeric for coded answers and numbers (the default). String only for free text, such as an “other (please specify)” answer. |
| Width and Decimals | How many digits or characters, and how many decimal places | Set Decimals to 0 for codes and whole numbers, so 3 shows as 3, not 3.00. Give string variables enough width for the longest answer. |
| Label | A longer description of the variable | The question wording, or a short version of it, such as “Q5 Satisfaction with library opening hours”. Labels can contain spaces and appear in your output tables. |
| Values | Value labels: what each code means | Click the cell, then the small button, and add each code and its label, for example 1 = Strongly disagree through to 5 = Strongly agree. |
| Missing | User-missing values | The codes you use for “no answer”, “don’t know” or “not applicable”, such as 99. See Step 4. |
| Columns and Align | How wide the column looks and how values line up in Data View | Display only. They do not change your data, so the defaults are usually fine. |
| Measure | The level of measurement | Nominal for categories with no order (gender, region), Ordinal for ordered categories (Likert items, education level), Scale for real measurements (age in years, income). |
| Role | A preset role used by some dialogs | Leave it as Input. IBM explains that roles only affect dialogs that support them and have no effect on command syntax. |
- Copy attributes across similar questions. If ten Likert items share one answer scale, set the Values cell once, copy it and paste it into the other rows.
- Use numbers, not words, for categories. Store “Agree” as 4 with a value label. IBM also warns that ordinal string variables sort alphabetically, so low, medium and high would sort as high, low, medium.
- Set Measure carefully. The variable type decides which tests you can use, as our guide on how to choose the right statistical test explains.
Step 2: Give every respondent an ID
Make your first variable a respondent ID, such as resp_id, and write the same number on each paper questionnaire. The ID lets you go back to the original when you find an odd value, and keeps each row tied to one respondent if you sort the file.
Step 3: Code each type of question
Single-choice questions
Questions with one answer, such as gender, region or highest qualification, get one variable each, with a code and value label for every option. Set Measure to Nominal, or Ordinal if the options have a natural order. For numbers people write in, such as age in years or income, enter the actual number and set Measure to Scale.
Likert items
Enter each Likert statement as its own variable, such as sat_1 to sat_5, with the same codes for every item (for example 1 = Strongly disagree to 5 = Strongly agree), and set each to Ordinal. Do not type totals by hand; let SPSS calculate them after checking.
Reverse-coded items
Some statements are worded the opposite way. In a satisfaction scale, “The library is often too noisy to study” runs against the others. Enter these as answered, then reverse them in a new variable so a high score means the same on every item:
- Choose Transform > Recode into Different Variables.
- Move the item, for example
sat_4, into the box, type a new name such assat_4rand a label, then click Change. - Click Old and New Values and add each pair: 1 becomes 5, 2 becomes 4, 3 stays 3, 4 becomes 2 and 5 becomes 1. Click Add after each pair.
- Add your missing-value code too (for example, 99 stays 99), or use System- or user-missing as the old value and System-missing as the new one. IBM notes that any old value you do not list becomes system-missing in the new variable.
- Click Continue, then OK, and give the new variable the same value labels as the other items.
This keeps the original answers. Use the reversed version when you build the scale score.
Multiple-response (“tick all that apply”) questions
A question such as “Which of these news sources do you use? Tick all that apply” cannot fit in one column. SPSS supports two ways to store it.
- Multiple dichotomy method. One variable per option, such as
news_tv,news_radioandnews_online, coded 1 = Ticked, 0 = Not ticked. This is the most common choice. - Multiple category method. As many variables as the most answers anyone gave, such as
news_atonews_c, each holding the code of an option chosen. IBM notes this suits questions with many options where people choose only a few.
To count the answers as one question, choose Analyze > Multiple Response > Define Variable Sets, select the variables, choose Dichotomies (with a counted value of 1) or Categories (with the range of codes), give the set a name and click Add. SPSS adds a $ sign to the name. Then run Analyze > Multiple Response > Frequencies or Crosstabs. These sets work only inside the Multiple Response procedures; Data > Define Multiple Response Sets is a separate option for Custom Tables and the Chart Builder.
Open-ended and “other (please specify)” answers
For an “other” option, use two variables: the main question with a code for “Other”, and a String variable, such as q7_other, holding what the respondent wrote. Type longer open answers into a String variable or a separate document linked by respondent ID, then group them into categories later. If open answers are a large part of your study, our guide on how to analyse qualitative data explains coding and themes.
Step 4: Code missing values properly
SPSS has two kinds of missing value, and mixing them up is a common source of wrong results.
- System-missing. If you leave a numeric cell blank, SPSS treats it as system-missing and shows a full stop (.) in Data View. It tells you nothing about why the answer is missing.
- User-missing. These are codes you choose and declare in the Missing column, such as 99 = No response, 98 = Don’t know or 97 = Not applicable. IBM explains that user-missing values are excluded from most calculations, and that you can define up to three individual values, a range, or a range plus one value.
Pick codes that can never be real answers. On a 1–5 Likert item, 99 is safe. For age, 99 might be a real age, so use 999. Then declare the codes in the Missing column. If you forget, SPSS treats 99 as a genuine answer and your averages will be badly wrong.
Step 5: Enter the data in Data View
Switch to Data View and type one questionnaire per row, from the ID to the last question.
- Enter the numbered questionnaires in order, typing codes, not words. The Value Labels button on the toolbar shows the labels so you can spot mistakes.
- Follow the codebook for unclear answers, and add any new rule you make to it.
- Save often. For important studies, have a second person re-enter a sample and compare.
How to import questionnaire data from Excel, Google Forms or a CSV file
From Excel
- Make sure the sheet has one header row of short names, one row per respondent, and no totals, notes or merged cells.
- In SPSS, choose File > Import Data > Excel and select the file.
- Pick the right worksheet and tick Read variable names from first row of data. IBM notes that headers that break the naming rules are converted to valid names, and the original headers are kept as variable labels.
- Click OK, then go to Variable View and fix every variable: add value labels, declare missing values and set the measurement level.
Watch for mixed columns. SPSS sets each column’s type from the share of values in one format, so “N/A” typed among numbers becomes system-missing, and a column with much text may be read as String. Clean these in Excel first.
From Google Forms or another online survey tool
In Google Forms, open the form, click Responses, then More (the three dots) and Download responses (.csv). In SPSS, choose File > Import Data > CSV and keep First line contains variable names ticked. IBM notes that this CSV import does not support line breaks inside quoted text, which can happen with long open-ended answers. If that is a problem, save the file as .xlsx and use the Excel import instead.
Online forms usually export answers as words, such as “Strongly agree”. After import, rename the variables to match your codebook and turn words into codes with Transform > Recode into Different Variables, which can recode a string variable into a numeric one. A “tick all that apply” question usually arrives as one column of comma-separated answers; split it into one 0/1 variable per option.
Step 6: Check and clean the data
Two quick procedures catch most problems:
- Analyze > Descriptive Statistics > Frequencies for every categorical variable. Look for codes that should not exist, such as a 6 on a five-point scale or a 3 for gender, and check how many answers are missing.
- Analyze > Descriptive Statistics > Descriptives for numeric variables. Look at the minimum and maximum. An age of 210 or a household size of 0 is almost always a typing error.
Use the respondent ID to find the original questionnaire and correct the value, rather than guessing. Also check skip logic: someone who has no phone should not name a network. Keep a log of corrections for your methodology.
Step 7: Save your file as .sav
Choose File > Save As and save in the SPSS Statistics (.sav) format. It keeps names, labels, value labels and missing-value codes, which a spreadsheet does not. Keep an untouched raw copy and work on a second copy. The Paste button in dialogs saves the commands as syntax, giving you a record of every recode.
An illustrative codebook for a short questionnaire
This codebook is illustrative and not taken from a real study. It shows how a short questionnaire on students’ use of a university library might be coded. Adapt the names and codes to your own instrument.
| Variable name | Label (question) | Values (codes) | Missing | Measure |
|---|---|---|---|---|
resp_id | Respondent ID | 1, 2, 3… (one per questionnaire) | None | Nominal |
gender | Q1 Gender | 1 = Male, 2 = Female, 3 = Prefer not to say | 99 = No response | Nominal |
age | Q2 Age in years | Actual age | 999 = No response | Scale |
faculty | Q3 Faculty | 1 = Arts, 2 = Sciences, 3 = Social Sciences, 4 = Engineering | 99 = No response | Nominal |
hours | Q4 Hours spent in the library per week | Actual hours | 999 = No response | Scale |
sat_1 to sat_5 | Q5a–Q5e Satisfaction statements | 1 = Strongly disagree, 2 = Disagree, 3 = Neutral, 4 = Agree, 5 = Strongly agree | 99 = No response | Ordinal |
sat_4r | Q5d reversed (“The library is often too noisy to study”) | Created with Recode into Different Variables: 1→5, 2→4, 3→3, 4→2, 5→1 | 99 = No response | Ordinal |
use_books, use_wifi, use_study, use_print | Q6 What do you use the library for? (tick all that apply) | 0 = Not ticked, 1 = Ticked | None | Nominal |
q7_main | Q7 Main reason for visiting | 1 = Study space, 2 = Borrowing books, 3 = Internet, 4 = Other | 99 = No response | Nominal |
q7_other | Q7 Other (please specify) | Text as written (String) | Blank | Nominal |
passed | Q8 Passed all courses last session? | 0 = No, 1 = Yes | 98 = Don’t know, 99 = No response | Nominal |
Common mistakes to avoid
- Typing words instead of codes, or several answers in one cell.
- An undeclared or unsafe missing code, such as 99 for age, counted as a real answer.
- Overwriting original items when reversing instead of recoding into a new variable.
- Sorting only some columns in Excel, which mixes up respondents’ answers.
- Skipping the checks before analysis.
Checklist before you start your analysis
- Codebook written and saved with the data
- Respondent ID in the first column
- Every variable named, labelled and given value labels
- Decimals set to 0 for codes
- Missing-value codes declared in the Missing column
- Measure set to nominal, ordinal or scale for each variable
- Reverse-coded items recoded into new variables
- Multiple-response questions stored as one variable per option or per answer
- Frequencies and Descriptives run, and errors corrected from the originals
- Raw copy and working copy saved as .sav
What to do next
With a clean dataset, start with descriptive statistics, then match each objective to a test using our guide on how to choose the right statistical test. A guide on how to analyse Likert scale data follows later this week. If your analysis plan is not settled, our guide on how to write a research proposal shows how to set it out.
Need help setting up or cleaning your SPSS data?
Erudite Digital Team is a research consultancy led by Eliakim Anzizi, PhD. We help researchers, students and organisations design codebooks, set up and clean SPSS datasets, and run and explain quantitative and qualitative analysis in SPSS, Stata, R, NVivo and Excel. See our data analysis service or start with our free services.
Sources
- IBM. Variable View, Variable names, Variable measurement level, Missing values and Roles. IBM SPSS Statistics 31 documentation.
- IBM. Recode into Different Variables and Recode into Different Variables: Old and New Values. IBM SPSS Statistics documentation.
- IBM. Multiple Response Define Sets and Multiple Response Analysis. IBM SPSS Statistics documentation.
- IBM. Reading Excel files and Reading CSV files. IBM SPSS Statistics documentation.
- IBM. Frequencies and Descriptives. IBM SPSS Statistics 31 documentation.
- Google. View and manage form responses. Google Docs Editors Help.
Frequently asked questions
How do I enter questionnaire data into SPSS?
Write a codebook first, then set up one variable per question in Variable View with a name, label, value labels, missing values and measurement level. Enter one row per respondent in Data View, or import from Excel or CSV, then check the data with Frequencies and Descriptives and save it as a .sav file.
How do I code Likert scale data in SPSS?
Enter each Likert statement as its own numeric variable, coded the same way for every item (for example 1 = Strongly disagree to 5 = Strongly agree), add value labels and set Measure to Ordinal. Reverse any negatively worded items with Transform > Recode into Different Variables before building a scale score.
How do I enter multiple response questions in SPSS?
Use the multiple dichotomy method (one 0/1 variable per option) or the multiple category method (one variable per answer given, holding the option code). Then group the variables with Analyze > Multiple Response > Define Variable Sets and run Multiple Response Frequencies.
How do I code missing values in SPSS?
Choose codes that cannot be real answers, such as 99 or 999, and declare them in the Missing column of Variable View so SPSS treats them as user-missing. Blank numeric cells become system-missing and show as a full stop.
Can I import questionnaire data from Excel or Google Forms into SPSS?
Yes. Use File > Import Data > Excel, or download Google Forms responses as a CSV file and use File > Import Data > CSV. Read variable names from the first row, then set value labels, missing values and measurement levels in Variable View.
Want your SPSS data set up or checked? Send a short description of your questionnaire and data on WhatsApp or by email. We reply with a clear plan. See our data analysis service.
Write it Right, Choose Erudite.