SDA 3.5 Documentation for makeddl.sps


NAME

makeddl.sps - Convert an SPSS file (.sav or .por) into DDL and data files

DESCRIPTION

MAKEDDL.SPS is an SPSS-Python script (provided courtesy of ICPSR) that converts an SPSS system file or portable file into the files required to set up the dataset in SDA -- namely, an ASCII data file and a DDL file.

Downloading and Installing the Script

Running the Script in SPSS

Once the data and DDL files have been generated, they can then be used to create an SDA dataset by running the regular MAKESDA program.


INSTALLING THE SCRIPT ON YOUR COMPUTER

From the SPSS Installation Disk

In order to run this script, SPSS 15 or higher must be installed on your machine (either Linux or Windows).

When SPSS is installed, you must also be sure to install the following software components from the SPSS installation disk:

From the SPSS Develper Central Web Site

In addition to Python and the SPSS-Python Integration Plug-in, you must also download and install five Python modules from the SPSS Developer Central site at: http://www.spss.com/devcentral

The necessary five modules are the following:

  1. spssaux
  2. spssdata
  3. extendedTransforms
  4. namedtuple
  5. trans

(Find each of these modules in the list of available modules on the SPSS Developer Central site, and download it.)

Python and the SPSS programmability plug-in must be installed first from the SPSS installation disk. After that, the SPSS auxiliary modules (’spssaux’ and the other four modules) should be installed in the Python installation’s "Lib\site-packages" directory (e.g.: C:\Python24\Lib\site-packages). When you install Python on your machine from the SPSS installation disk, note the location of the Python directory so that you will know where to install the SPSS auxiliary modules.

The only thing that needs to be modified for different datasets is the script. The appropriate study title and pathnames need to be inserted into the script, so that you read the correct SPSS file and write the data and DDL files into the desired locations.

Installing Components Separately

If you are not using an SPSS Installation Disk for Windows, it may be necessary to download some of the required components from other sources.

However, if you download these components from the Web be sure to consult the installation instructions for the integration plug-in for your version of SPSS. Warning: different versions of SPSS require different versions of Python and of the integration plug-in. For the plug-in installation instructions, and lots of other useful documentation about using Python with SPSS, see the SPSS Developer Central site.

In addition to Python and the SPSS-Python Integration Plug-in, you must also download and install the same five Python modules mentioned above from the SPSS Developer Central site.


EDITING THE SCRIPT FOR A PARTICULAR DATASET

Once the ’makeddl.sps’ script has been installed, you still need to edit it for a particular dataset. When running SPSS in Windows, it is easy to use the SPSS Syntax Editor which appears when you start up the script. Or you can use any text editor.

The point of the editing is to tell SPSS where to get the input SPSS file, and where to put the output data and DDL files. You also specify the study title that you want to appear in the DDL file.

The four lines of the script to edit are lines 108-111. This is what that section of the script looks like:


# EDIT HERE:  Specify dataset title, input and output filenames
#
# IMPORTANT:  Be sure to use forward slashes (/), NOT back
# slashes (\) between directories in path specifications, e.g.,
#
#    asciidata_out = ’h:/mydir/sda/mydata.txt’
#
#===================================================
# USER-DEFINED SPECIFICATIONS:
#===============================

title = ’SDA Dataset Title’
spssdata_in = ’spssdata’            # Must be .sav or .por
asciidata_out = ’asciidata.txt’
ddlfile_out = ’myddl.txt’

You need to replace the content of the last four lines above with the appropriate specifications for the dataset for which you want to generate data and DDL files. An example is the following:
title = ’Survey of Political Attitudes’
spssdata_in = ’c:/myaccount/politdata.sav’
asciidata_out = ’c:/myaccount/politdata.txt’
ddlfile_out = ’c:/myaccount/politDDL.txt’
Notice that full pathnames are given for the files, and the location of the files is specified using forward slashes, even for Windows. If the input SPSS file is an SPSS Portable File, be sure to use the ’.por’ suffix (instead of the ’.sav’ suffice) for the name of the SPSS file. The corresponding Portable File version for this example would be:
spssdata_in = ’c:/myaccount/politdata.por’

When you have completed this editing, the script is ready to run.


SEE ALSO

DDL Data Description Language used by SDA Programs
xconvert Convert SPSS/SAS/Stata syntax files to DDL
ddltox SDA program to convert DDL files to SPSS/SAS/Stata/DDI


CSM, UC Berkeley
April 12, 2011