Scripts are relatively new to SPSS. If you have never used Visual Basic (VB) or Visual
Basic for Applications (VBA), you will find the learning curve to be pretty steep. SPSS
uses Sax Basic developed by Sax Software. By adding Sax's Type Library to your
favourite VB development environment (for instance, VB6, Excel or Access) you may develop
your SPSS scripts using those development environments.
Scripts allow the user to do things which would not be possible using syntax, for
instance formatting an IGRAPH or having error handlers. Whenever possible, I prefer to use
syntax instead of scripts. As my knowledge of syntax increased, I discovered ways to
do things which I previously thought only scripting could do, one such example is
exporting or creating a variable which contains the value labels of another
variable.
Scripts can be called from syntax and vice versa. However a major problem is that a
script called from anywhere in a syntax could be executed after the
syntax file has finished! The same problem exists when a script calls a
syntax, that syntax could only be executed once the script has finished.
Starting with version 14, Python scripts run synchronously with syntax files.
The asynchronous problem is thus resolved. See Self
adjusting code for examples.
Note that Scripting is not available in SPSS for Mac.
** Important Download Instructions **
Note: At the suggestion of a visitor, I have changed the extension of
the *.sbs files to *.txt, this makes it easier to look at the files online. When you click on an *.sbs file below,
it opens up in your browser as a text file. If you like what you see,
go
back to the prior page, right click on the file name as select "Save target
as").
Copying the code and pasting it directly into an SPSS script window sometimes results in the loss
of the line breaks; all lines are saved consecutively in the same line, this is
not very useful :-(
Apply String
Length.SBS 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
Generate
Random variables_EN.SBS
with thanks to Kirill Orlov. Creates random variables with various
options (eg correlated, rounded, with missing values etc)
Send a document as an attachment to an email.SBS
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.
Export
data from Excel to PowerPoint.zip This VB.NET program (author Kirill Orlov)
is for those who fill PowerPoint charts with data from Excel (e.g. data of Pivot Tables exported to Excel from SPSS output). Help documentcontains
is included;
SPSS_to_STATA_01.SBS
with thanks to Alasdair Crockett. This is
the conversion
guide explaining how to use the script. This scripts will be
useful to those using SPSS versions older than v14 (since v14
automatically reads / writes stata files).
Export2Triple-S.SBS(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.
Autoscript
to format correlation table.sbs(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)
Run
Designated Syntax in Batch Mode.SBS 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.
Syntax script.sbs This is
Fabrizio script to circumvent the asynchronous problem. You must ensure that there
are no trailing spaces at the end of the syntax.
Combine all .sav files
in the given folder.SBS (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)
Combine
all sav or text files in given folder.SBS 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.
This program has been written by Alexis-Michel Mugabushaka
of the University of Kassel, Germany. The program is similar to SPSS Production's
facility. You feed the program with a list of syntax files or a file containing a list of
syntax files. The program runs each syntax one by one and create a separate output
file for each of the syntax file and having the same name as the syntax file. See
also Break Output File
into Smaller Pieces.SBS
ViewSav is a Real-Time Codebook for SPSS data files. It
has been written by Karel Asselberghs from the Sociology Department,
University of Amsterdam. He has also 2 other SPSS utilities:CRC32SAV and LISTSAV.
The first one computes checksums for separate parts of a SPSS data file:
file header, dictionnary and data. This enables you to check if these areas of 2 sav files
are identical. The second one list variables and variable labels of a SPSS data file.
(source code included).