Skip to content
Tutorials Center
My learning

Topics

Lesson 9 of 39 ยท Interface and Data

Saving, Exporting and SPSS File Types (.sav, .sps, .spv)

Save SPSS data safely, keep variable properties, export data to Excel and CSV, export output to Word and PDF, organize project files and recover work with the journal file.

You will lose work at some point: a crash, an overwritten file, a colleague who cannot open your data. Good saving habits make that survivable. This lesson covers how SPSS saves data, how to share it in other formats, how to export results and how to keep a project tidy.

The three native files

File Contents Save from
.sav Data and the data dictionary (names, labels, value labels, missing codes, measure) Data Editor: File > Save or Save As
.sps Syntax (plain text commands) Syntax Editor: File > Save
.spv Output Viewer contents (tables, charts, log) Output Viewer: File > Save

.zsav is a compressed .sav (smaller on disk, same content; tick Save data in compressed format in Save As). .por is an old portable format; use it only to talk to very old software.

Each window saves its own file. Saving the data does not save the output or syntax, and vice versa. If you close SPSS, it asks about each unsaved window separately; read the prompts.

Saving data: Save As options

File > Save As... gives these choices:

  • Save as type: SPSS Statistics (*.sav), compressed, Excel, CSV, tab-delimited text, SAS, Stata, dBase and others.
  • Keep only N of N variables: Variables... lets you choose which columns to write. Useful for sharing a subset.
  • Write variable names to spreadsheet and Save value labels where defined instead of data values for Excel, CSV and text outputs.
  • Encrypt file with password for .sav files.

The syntax is SAVE OUTFILE:

TEXT
SAVE OUTFILE='C:\project\cafe_clean.sav'
  /KEEP=id gender age visits rating
  /COMPRESSED.

SAVE TRANSLATE OUTFILE='C:\project\cafe_clean.xlsx'
  /TYPE=XLS /VERSION=12 /FIELDNAMES /CELLS=VALUES /REPLACE.

/KEEP selects and orders columns; /DROP removes them. /CELLS=LABELS writes value labels instead of codes. Note: Save As changes the active dataset's name, so later commands refer to the new file. An ordinary Save after changes to a .sav overwrites the file with no undo.

Never edit your only copy of the raw data. Keep an untouched raw file and write the cleaned data to a new .sav. All the changes should live in syntax, so that you can rebuild the cleaned file from the raw one.

Sharing data with other programs

Exports to CSV and Excel keep values only; the dictionary does not travel. To preserve meaning:

  • export value labels instead of codes if the reader needs words (but then numeric codes disappear; export both versions or add a code book);
  • write the variable labels to a separate code book with File > Display Data File Information > Working File (copy the table into Word);
  • use Stata (.dta) or SAS formats when the receiver uses those programs; they keep more of the dictionary.

R and Python can read .sav files (for example with pyreadstat or haven) and keep labels, so sharing the .sav itself is often best.

Python Stand-in: codes vs labels in an export

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Exporting output

Click in the Output Viewer and choose File > Export.... In the Export Output dialog:

  1. Objects to Export: All, All Visible or Selected.
  2. Document > Type: Word/RTF (.doc), Excel (.xls, .xlsx), PowerPoint, PDF, HTML, Web Report, Text, or None (graphics only) for images (PNG, JPEG, TIFF, EPS and more).
  3. File Name and, for Word, whether to Wide tables: wrap / shrink to fit / no change.
  4. Change Options... to control layout, page size and whether to include notes and hidden items.

Quick alternatives: select a table, Edit > Copy and paste into Word as a table, or Copy Special (paste as picture or as text). Right-click a chart to Export... as an image file. In syntax, use OUTPUT EXPORT:

TEXT
OUTPUT EXPORT
  /CONTENTS EXPORT=VISIBLE LAYERS=PRINTSETTING MODELVIEWS=PRINTSETTING
  /PDF DOCUMENTFILE='C:\project\results.pdf'.

OUTPUT SAVE OUTFILE='...spv'. saves the output file from syntax. Use OUTPUT NEW. to start a fresh Output Viewer and OUTPUT CLOSE *. to close it.

Organizing a project

A tidy folder prevents confusion:

flowchart TD
    P["project/"] --> R["data_raw/<br/>original files, never edited"]
    P --> C["data_clean/<br/>cleaned .sav files"]
    P --> S["syntax/<br/>01_import.sps, 02_clean.sps, 03_analysis.sps"]
    P --> O["output/<br/>.spv and exported PDF/Word"]
    P --> D["docs/<br/>code book, notes"]

One folder per kind of file keeps raw data safe and results reproducible.

Number syntax files in running order. Put a header comment in each one (author, date, purpose, input and output files). Use relative CD commands or a single FILE HANDLE at the top so you can move the project:

TEXT
FILE HANDLE project /NAME='C:\project'.
GET FILE='project\data_clean\cafe_clean.sav'.
Python Stand-in: a descriptive file name for each output

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Recovery

SPSS keeps a journal (statistics.jnl) that records every command it executes, including those from dialogs. Its location is under Edit > Options > File Locations > Session Journal. After a crash, open the journal in a text editor and copy the commands you need into a new .sps. SPSS may also offer to recover unsaved work. Do not rely on this: save early, and use File > Save often.

Common mistakes

  • Saving over the raw data after recoding.
  • Exporting a CSV and believing labels came with it.
  • Saving only the data and losing the Output Viewer results (or the reverse).
  • Giving files names such as final.sav, final2.sav, really_final.sav. Use dates or version numbers.
  • Storing the project in a synced cloud folder that locks files while SPSS writes.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which file keeps value labels and missing-value declarations together with the data?

    The .sav file stores the data and its dictionary. CSV and text files hold values only.
  2. 2. Which export option writes 'Female' instead of 1 in an Excel or CSV file?

    That option replaces codes by their labels in the exported file.
  3. 3. Where do commands you ran, including from dialogs, get recorded so you can recover them after a crash?

    The session journal file logs every executed command.
  4. 4. Why keep an unmodified raw data file?

    With raw data and syntax you can reproduce every change; with only an edited file you cannot.

Summary

  • .sav holds data plus dictionary, .sps holds syntax, .spv holds output; each is saved from its own window.
  • Use Save As or SAVE OUTFILE (with /KEEP, /DROP) to write subsets or other formats; CSV and Excel lose the dictionary unless you export labels or a code book.
  • Export output with File > Export or OUTPUT EXPORT to Word, PDF, Excel, HTML or images.
  • Organize a project in folders, number syntax files and never edit the raw data.
  • The session journal can recover commands after a crash, but frequent saving is the real protection.

Next: Recode and Binning: Changing and Grouping Values