Guides

Guide

Survey codebook template for Excel and SPSS

What a survey codebook is

A survey codebook is the key to a data file. It lists every variable by its short name, the question it came from, its type, and what each stored number means. With it, anyone who opens the data in Excel or SPSS can turn a 2 back into "No" without asking the person who wrote the survey.

You may also hear it called a data map or a data dictionary. In everyday use they mean the same thing. This guide covers what goes in one, how to code each kind of question, and gives you a CSV template to start from.

What goes in a codebook

A codebook has one row for every answer code, grouped by variable. The template uses seven columns:

  • Variable. The column name in the data file, such as S1 or S2_1.
  • Question. The wording as people saw it. For a multiple-response option, add the option text.
  • Type. Single choice, multiple choice, a scale, a number, open text and so on.
  • Code. The number stored in the data for an answer.
  • Label. What that number means, such as Yes or 25 to 34.
  • Asked of. Who saw the question, written as a condition, such as S1 = 1. This tells the analyst the right base. See base size in survey research.
  • Notes. Routing, screen-outs, and anything the next person needs to know.

The first five are the core of any codebook. The last two save the next person a lot of questions.

Question codes: the S1, S2, S3 style

Give every question a short, stable code before fieldwork starts. A common pattern uses a letter for the section and a number for the order:

  • S for screener questions: S1, S2, S3.
  • Q for the main questionnaire: Q1, Q2, Q3.
  • D for demographics: D1, D2.

Good codes follow a few rules:

  • Start with a letter and use no spaces. SPSS variable names allow no spaces and are safest starting with a letter, and the same names then work as Excel column headers.
  • Keep them stable. If you insert a question between Q3 and Q4 after the survey is live, call it Q3a rather than renumbering everything after it. Renumbering breaks every rule, table and comparison that used the old codes.
  • Keep them short. Codes appear as column headers and in routing rules.

In Survizo, every question has a code. Type your own, such as SATISFACTION, or leave it blank and it becomes Q1, Q2 and so on by position. Rules, quotas and piping all refer to questions by code, and a script imported from Word keeps its codes exactly as written. See surveys and logic.

A worked example

Here is an illustrative screener, not a real study:

  • S1. Do you own a smartwatch? 1 Yes, 2 No. If S1 = 2, screen out.
  • S2. Which of these do you use it for? (Select all) 1 Heart rate, 2 Sleep, 3 Payments.
  • S3. How likely are you to recommend it? (0 to 10) If S3 is less than 7, go to S5.

It produces these data columns:

ColumnHolds
S11 for Yes, 2 for No
S2_1, S2_2, S2_31 when that option was chosen, blank when not
S3The score, 0 to 10

The template carries this example on, with an open question, a frequency question and an age group.

Coding single-choice questions

A single-choice question gets one column. Each answer gets a whole number, usually in the order the answers were shown: 1, 2, 3. Two habits help:

  • Keep codes the same across waves. If "Weekly" was 2 in the first wave, it stays 2 in every later wave, even if you add a new answer. Add the new answer at the end with the next free number.
  • Set aside codes for non-answers. Many teams reserve a high number, such as 99 for "Prefer not to say", so it sorts to the end and is easy to leave out of averages.

Coding multiple-response questions

A multiple-response question, where people can pick several answers, needs more than one column. Give each option its own column, named with the question code, an underscore and the option number: S2_1, S2_2, S2_3.

Each column then holds a marker for whether that option was chosen. There are two conventions for "not chosen": a 0, or a blank. Whichever you use, be clear about the difference between two kinds of empty:

  • Not chosen. The person saw the question and did not pick this option.
  • Not asked. Routing skipped the question, so the person never saw it.

The Asked of column settles this. If S2 was asked only of S1 = 1, then everyone with S1 = 1 is in the base, and a blank in S2_1 means they did not choose heart rate.

Remember that percentages on a multiple-response question are of people, not of answers, so they can add up to more than 100%. In SPSS, you can group the option columns into a multiple-response set, counting the value 1, to table them together.

Labels, values and measurement levels

SPSS stores two kinds of label, and a good codebook gives you both:

  • A variable label, the question wording, so a table says "Do you own a smartwatch?" and not just S1.
  • Value labels, one for each code, so a table says Yes and No and not 1 and 2.

It also helps to note each variable's measurement level:

  • Nominal for categories with no order, such as brand or region. A single choice with an order, such as an age band, is ordinal.
  • Ordinal for ordered categories, such as a rating scale or a ranking.
  • Scale for real numbers, such as a slider or a count.

For a 0 to 10 scale, store the score itself as a number, so it can be averaged, and label only the end points, as people saw them, so tables stay readable.

Open text and missing answers

Open text is kept word for word and has no value labels. If you code it into themes, keep that in a separate code frame with its own variables, and leave the original text untouched.

A question someone did not answer should stay missing, never zero. A zero in a numeric column is a real answer and pulls an average down. A blank is not counted at all.

The template

Download the codebook template (CSV)

The template opens in Excel, and you can work through it as a checklist while you set variable and value labels in SPSS. The template in full is at the end of this guide, row by row.

How Survizo writes the codebook for you

If you run the survey in Survizo, the codebook is written for you. Export from the Data tab and the Excel workbook adds a Data sheet of answer codes, one row per response, with a Datamap codebook beside it. The Datamap's columns are Variable, Question, Type, Code and Label, the first five columns of the template.

The SPSS .sav file uses the same columns, with the question wording, answer labels and measurement levels already set. Choice questions are set to nominal, so change ordered ones, such as an age band, if you need to. Each multiple-choice option is its own column, holding 1 when chosen, and a question someone did not answer stays missing, never zero. See analysis and exports.

To see your own script come out as a workbook and a .sav file, book a fit call.

Frequently asked questions

What is the difference between a codebook and a data map?

In everyday use, none: both list each variable and code with its question and label. A full study codebook may also carry notes on sampling, weighting and fieldwork.

How do I code a multiple-response question?

Give each option its own column, named with the question code and the option number, such as S2_1 and S2_2. Each column holds 1 when that option was chosen. Record who was asked, so a blank can be read as "not chosen" rather than "not asked".

Should a missing answer be 0 or blank?

Blank. A zero in a numeric column is a real answer and changes averages. A blank is left out. For a multiple-response option, a blank or a 0 can mean "not chosen", but only among the people who were asked.

What makes a good variable name for SPSS?

Start with a letter, use no spaces, keep it short and keep it the same for the life of the study. The S1, S2, S3 style does all four.

Can I use the template in Excel?

Yes. The template is a CSV file, so it opens in Excel as a sheet with seven columns. Replace the example rows with your own questions and codes.

The template in full

Download the codebook template (CSV)

Each row below is a row of the CSV file, in order. Blank cells are blank in the file too.

VariableQuestionTypeCodeLabelAsked ofNotes
RESPIDRespondent IDIDEveryoneOne row per respondent in the data sheet
S1Do you own a smartwatch?Single choice1YesEveryone
S12NoScreen out at S1 = 2
S2_1Which of these do you use it for? Heart rateMultiple choice1ChosenS1 = 1Blank = not chosen
S2_2Which of these do you use it for? SleepMultiple choice1ChosenS1 = 1Blank = not chosen
S2_3Which of these do you use it for? PaymentsMultiple choice1ChosenS1 = 1Blank = not chosen
S3How likely are you to recommend it? (0 to 10)Scale 0 to 100Not at all likelyS1 = 1Stored as the score; label the end points only. Routing: IF S3 < 7, GO TO S5
S310Extremely likely
S4What do you like most about it?Open textS3 = 7 to 10Kept word for word; code into themes in a separate frame
S5How often do you wear it?Single choice1Every dayS1 = 1
S52Most days
S53Now and then
D1Which age group are you in?Single choice118 to 24S1 = 1
D1225 to 34
D1335 to 54
D1455 or over
D199Prefer not to sayExclude from averages

The next step

Book a fit call.

Bring a study you're planning to a thirty-minute fit call. We'll walk through it on Survizo with you and tell you how soon you could start.

We answer within one working day, Monday to Friday, UK time. We use these details to arrange the call and to keep a record of our conversation. Privacy