Chapter 18. Scripts

In This Chapter

  • Scripting with Sax BASIC for SPSS

  • Examining BASIC classes and objects for SPSS

  • Creating global and automatic scripts

You can write BASIC language programs that run inside SPSS. Such programs are known to SPSS as scripts. SPSS has a dialog box specially designed for editing these scripts, running them, and saving them to disk. When you write scripts, you have the advantage that the Sax BASIC language is common and widespread — making it easy to find documentation, both in print form and on the Internet. A good deal of documentation is also available inside the SPSS help system.

Although scripts can be made to work with input data, they primarily work with output data — the data displayed in SPSS Viewer. For example, you can use a script to add items to or delete items from a pivot table. Also, you can write a script to modify a graph after it has been displayed.

Picking Up BASIC

This chapter is not a tutorial on programming using the BASIC language. (You can get that information from Internet tutorials and from books on Sax BASIC and Visual BASIC.) This chapter is about the particulars of using BASIC as a scripting language inside SPSS.

You should always start writing a new script by copying an old script that works. SPSS provides a number of starter scripts for you to use for this very purpose. Before you write a script of your own, look through this collection and get familiar with the available scripts. They're complete, working scripts; one of them ...

Get SPSS For Dummies®, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.