Export SPSS Pivot Tables to Excel with OUTPUT EXPORT Syntax
Export SPSS pivot tables directly to Excel using the correct OUTPUT EXPORT syntax, with example code, version notes, and common pitfalls to avoid.
06 Sept 2025, 09:38 UTC

Quick answer
To export a pivot table that is currently visible in the SPSS Viewer to an Excel file, run the OUTPUT EXPORT command with the /EXCEL subcommand. No EXECUTE line is needed; the command runs when the syntax block is processed.
How it works
OUTPUT EXPORT writes selected output objects (tables, charts, text) to a file you specify. For Excel output you use the /EXCEL subcommand, which creates or appends to an .xlsx file. The command exports only objects that are visible in the Viewer at the moment the syntax runs; hidden items are skipped. You identify the object to export with /OUTPUTNAME (matching the name shown in the Viewer’s outline pane). If you omit /OUTPUTNAME, all visible objects are exported.
Example syntax
* Make sure the pivot table you want is the top‑most visible item in the Viewer.
OUTPUT EXPORT
/EXCEL DOCUMENTFILE='C:\\temp\\MyPivotTable.xlsx' OPERATION=CREATEFILE
/OUTPUTNAME 'PivotTable1'.
Place the block in a SPSS Syntax Editor window and run it. SPSS creates MyPivotTable.xlsx in the C:\temp folder containing the pivot table’s values.
Limitations and common mistakes
- Version requirement:
OUTPUT EXPORTwith the/EXCEL subcommand has been available since SPSS version 15. Earlier releases lack this exact syntax. - Visible objects only: If the pivot table is hidden, minimized, or not the active visible object, it will not be exported. Ensure it is visible in the Viewer before running the syntax.
- File‑path formatting: Inside quoted strings, a single backslash is treated as an escape character only when it forms a valid escape sequence (e.g.,
\n). To avoid unintended escapes, use double backslashes (\\) or forward slashes (/) in theDOCUMENTFILEvalue. - Incorrect object name: The string supplied to
/OUTPUTNAMEmust exactly match the pivot table’s name as shown in the Viewer outline pane (including spaces). A mismatch results in an empty export or a warning in the log. - Formatting loss: Cell values and the basic layout transfer correctly, but SPSS‑specific cell styles (fonts, colours, conditional formatting) are not preserved in the Excel file.
- Multiple tables: Exporting a complex output that contains several tables or charts may require separate
OUTPUT EXPORTcalls, each naming the desired object, because the command exports one object per/OUTPUTNAME(or all visible objects if omitted).
Verification steps
- Run the syntax block above with the desired pivot table visible in the Viewer.
- Check the SPSS log (View → Log) for any warnings about missing visible objects or invalid file paths.
- Navigate to the folder specified in
DOCUMENTFILEand open the generated.xlsxfile. - Confirm that the table’s values and layout match what you saw in the Viewer.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.