1. Printing
  2. Working with Many Files
  3. Output Document
  4. Transform variable
  5. Autoscripts
  6. Long variable names
  8. Data Editor
  9. Utilities
  10. Dialogs
  11. Distributions
  12. Export & Import
  13. Labels, Variable Names and Format
  14. Matrix
  15. Syntax Editor
  16. Output format
  17. Manipulating Pivot Tables
Show me data and I will show you data errors!



  1. Print all spo files in a given folder
  2. Print current syntax with file path, date, time and page (It is convenient to attach that script to a new toolbar button in the script window)
  3. Print data filename and path as part of output footer
  4. Print options (this is called by next syntax)
  5. Print options.sps (from AnswerNet)
  6. Print orientation (Add heading, date, time, page numbers to printout)
  7. Toggle display of page numbers in Output window
  8. Set Parameters for Printing via Syntax

Working with Many Files

  1. Combine all .sav files in the given (only file path and mask is supplied, script does the rest… The resulting sav file contains a variable identifying the source file of each case)
  2. Combine all sav or text files in given folder This is a generalization of the preceding script, this one combines either sav or txt files. A variable in the final file contains the name of the file where the case comes from. Of course the DATA LIST commands must be adapted to each particular situation.
  3. Convert all files in folder into other formats Can convert from 
    *sav to *.por
    *.por to *.sav
    *.sav to *.xls
  4. Create as many sav files as there are txt files
  5. List all files in given folder
  6. Run Same Syntax on 17 Zipped Files

Output Document

  1. Empty designated output window
  2. Demo of script work to add page breaks
  3. Delete statistics and case processing summary
  4. Break output file into smaller pieces (AnswerNet)
  5. Add page breaks at selected places (an easy to use script to automatically insert page breaks before any specified pivot tables).
  6. Change label title of last run procedure (With thanks to Michael Wexler)
  7. Create new Output with a given filename and file path
  8. Data footer (sets footer of Output to name and path of .sav file)
  9. Insert a text object into the SPSS Viewer
  10. Produce a Table of Content (TOC) listing all pivot tables
  11. Remove page breaks
  12. Replace left pane PageTitle by content of right pane (Useful to help locate given areas of the output navigator)
  13. Save current output window-by script
  14. Search label in Output Window
  15. Select last table in current output
  16. Write index in output navigator
  17. Add footnotes to every Pivot Tables
  18. Extract Information From a Text Output (syntax that uses script)
  19. Extract Information From a Text Output (script used by syntax)
  20. Save Current Output Windows (script used by syntax)
  21. Save Current Output Windows (syntax that uses script)

Transform variable

  1. Define missing for all numeric variables
  2. Standardize within case


  1. Bold Total In SUMMARIZE table Or Insert Page Break
  2. Bold Total in SUMMARIZE table or insert Page Break This is an example of a syntax which passes an argument to an autoscript. This can be very useful.
  3. Debugging Automation

Long variable names

  1. Scripts for Switching between short and long variable names
  2. Short .por-names to Long
  3. Rename Long to Short (syntax that uses script)
  4. Rename Long to Short These scripts allow switching between long and short variable names (used with syntax).


  1. Change bar colors for each IGRAPH bar chart with only an x-axis
  2. Format IGRAPH
  3. Format IGRAPH (this syntax creates data, two graphics then calls the above script)
  4. Export All IGRAPH to Jpeg of a given size
  5. Export current IGRAPH to Jpeg of a given size

Data Editor

  1. Apply String Length This automatically reformats all string variables of any sav file to the format of the string variable having same name in a Template.sav file
  2. Find number of cases (works for weighted and un-weighted files)
  3. Create empty data file with n cases n is supplied by the user at run time)
  4. Set data editor column width to match variable length
  5. Load data file and print data values in
  6. Split current data file in n random groups (n is supplied by the user at run time)
  7. Display number of variables and cases in data file


  1. Automatically run a script or syntax when SPSS starts
  2. Create new output window
  3. Illustrate windows state (how to minimize, maximize a window)
  4. Call script B from script A
  5. Add file date to file names in a given folder
  6. Automatically gets data and output HTML files every hour
  7. Convert syntax into script format (with thanks to Rolf Kjoeller)
  8. Script to run a DOS command or Bat file code by Fabrizio
  9. Multi purpose script: (run Sub based on syntax call)
  10. Name data file based on date read from data file
  11. Toggle Output Type (with thanks to Karel Asselberghs)
  12. Terminate syntax with period
  13. Write table of content of output navigator to text file
  14. Running Script from Syntax - 2
  15. Running Script from Syntax This is Fabrizio script to circumvent the asynchronous problem. You must ensure that there are no trailing spaces at the end of the syntax.
  16. Levenshtein Distance between 2 strings
  17. Levenshtein Distance Between 2 Strings (syntax that uses script)


  1. Get a file name from the user
  2. Get file name from user then define path by macro
  3. Get Fiscal Year from user then run syntax for that year
  4. Get user name then define a usrname macro
  5. Variable list demo1 (from SPSS site)
  6. Variable list demo2 (from SPSS site)
  7. Variable list demo3 (from SPSS site)
  8. Empty Designated Draft Output


  1. Distribution plot
  2. Distribution
  3. Generate Random Variables with thanks to Kirill Orlov. Creates random variables with various options (eg correlated, rounded, with missing values etc)

Export & Import

  1. Export spss Output viewer to XML
  2. Export pivot table data cells to data editor
  3. Export labels from MS Access to SPSS This is Visual Basic code.
  4. Save all attachments of emails to a given folder (This is an Outlook VB Script) all emails in a given Outlook folder are processed)
  5. Send a document as an attachment to an email This SaxBasic script uses Outlook 2000 to send an email to a recipient with an attachment, the attachment could be an HTML page produced by SPSS, and spo file or any other documents.
  6. Convert to Excel 5_95 format SPSS exports to Excel 2.1; this automatically converts the file to Excel 5/95 format.
  7. Export tables to a single excel sheet
  8. Export tables to a single excel sheet v2 This exports then groups the lines forming a table. Very convenient.
  9. ExportTablesToSingleExcelSheetV3 Similar to above script however this one also exports CHARTS and IGRAPHS.
  10. ExportTablesToSingleExcelSheetV4 As an improvement to V3, this one exports all layers of Pivot Tables.
  11. Export Pivot Tables to PowerPoint
  12. Change background color of all IGRAPHs in Viewer
  13. Export all pivot tables of all spo files to HTM file (only spo files meeting a given path and file mask are processed. One HTM file is created per SPO file).
  14. Export target items of all spo files to HTM file (this is an extension of above script. This one handles IGRAPH in addition to Pivot Table and Charts)
  15. Export Data Dictionary to text files With thanks to Jean-francois Allaire)
  16. Export Pivot Tables to Word2 (original by SPSS, modified by John Hendrickx to format tables)
  17. Export sav file to free format
  18. Export visible output to word via HTML v2 (here the graphs are embedded in the word document)
  19. Export content of data editor to XML format v2 (This version is for SPSS version 11 and up). (See the above note)
  20. Export to Triple-S (this script creates a Triple-S v1.2 XML file and related data file from the current SPSS data file). Thanks to the author Chris Johnson for sending it.
  21. Export Data from SPSS to Pulsar Beta 0.16 (with thanks to Alexander Bougakov). This is based on the above script by Chris Johnson.
  22. Add or Update Data from Excel to PowerPoint Chart This is archive with VB .NET program
  23. From SPSS to STATA

Labels, Variable Names and Format

  1. Scripts for Switching between short and long variable names
  2. Add extension to all variable names
  3. Add the word "index" at the beginning of all variable labels
  4. Add value labels
  5. Add value labels using a loop
  6. Add variable name at beginning of variable label
  7. Assign variable label equal to variable name (can also be done with syntax)
  8. Capitalise variable and value labels
  9. Define macro calls for each value label Example2 (This is a useful programming tool)
  10. Define macros giving variable labels (can also be done with syntax)
  11. Delete value labels of all variables
  12. Export variable and value labels to txt files (thanks to Wouter Egberink for sending me this code)
  13. Export variable name and variable labels to text file
  14. Populate variable with value labels of another variable (can also be done with syntax)
  15. Reverse autorecode To create a new string variable containing the value labels of an existing variable (this can also be done using syntax alone)
  16. Reverse auto recode10 Use this version for SPSS v10 and over.


  1. Maximizing the trace of a matrix This is high powered stuff. Need to test all permutations of rows in order to find the one which maximizes the trace. For a 7*7 matrix (the maximum size this macro will handle), there are 5,040 permutations to test.

Syntax Editor

  1. Close All Syntax Doc
  2. Convert Syntax To Script
  3. Find and replace block of text in syntax window
  4. Paste text at the end of syntax window
  5. Run Designated Syntax in Batch Mode I find this very useful, for convenience associate it to a custom made button on your syntax toolbar. Click the button when you want the Designated Syntax to run up to the first error.
  6. Write syntax file defining variable and value labels

Output format

  1. Apply Table look to all output
  2. Apply autofit
  3. Change pivot table text (This is useful to change column or row labels from English to other languages)
  4. Frequencies footnote
  5. Size labels to avoid line-wrapping

Manipulating Pivot Tables

  1. Set number decimals of percentages in PivotTable
  2. Undo percent notation
  3. Remove pivot table row and column labels
  4. Applying any script to all pivot tables
  5. Automation of pivotting (Examples to learn how to manipulate layers, columns and rows)
  6. Autoscript to format correlation table (this removes upper diagonal, highlights significant correlations, moves N's and Sig's to the Layer's dimension to hide them) With thanks to Ferd Britton)
  7. Change Sig to P
  8. Combine mean and SD (called from this syntax)
  9. Combine Mean and SD
  10. Create pivot table
  11. Crop and retain (Thanks to Mark Baxter)
  12. Cycling through all layers of a table
  13. Define customized crosstab titles Note: to avoid asynchronous problem, the script could be modified to check all documents in the Output window. The script would then be called only once.
  14. Delete footnotes of all Pivot Tables
  15. Exchange rows and columns of Pivot Table
  16. Hide valid and valid percentage in frequency table
  17. Hide a column in pivot table
  18. Highlights significant cells of all ANOVA tables in Designated Viewer This is an example of Applying a script to all (ANOVA) pivot tables in the Designated Viewer.
  19. Highlight significant T-Test cells
  20. Italize percentages in PivotTable
  21. Left right or center justify title of all pivot tables
  22. Create pivot table-ROC (called from this syntax)
  23. Create pivot table-ROC
  24. Make totals bold This applies only to the currently selected Pivot Table. Can also change the color of applicable cells.
  25. Make Totals Bold All Pivot Tables Similar to the above script but applies to all visible Pivot Tables in the Designated Viewer
  26. Pivoting to each layer of a pivot table
  27. Remove percent signs from PivotTable
  28. Replacing Empty Cells of Pivot Tables by user-defined characters
  29. Rotate inner labels of all visible PivotTables
  30. Round frequencies in crosstab tables
  31. Reverse columns order
  32. Ungroup a column in a pivot table
  33. Set number of decimals in pivot table
  34. Substitute string in pivot tables
  35. Traffic Light
  36. Traffic Light with Fixed Margins 15 and 25
  37. Traffic Light with 3 Cut Off Points
  38. Mark Significance Levels in Tables
  39. Change Format Means Report (syntax that uses script)
  40. Change Format Means Report (script used by syntax)
  41. Table Widths (syntax that uses script)
  42. Table Widths (Thanks to Jason Burke for this improved version). This is script, used by syntax
  43. Undo Scientific (##.#E±##) Notation (standard procedure from file Global.SBS)