SPSS: Creating and reading permanent SPSS data sets


Example for UNIX

Creating a permanent SPSS data set
The name of the command file for this example is

	income.spss  
It shows how to read data from an external data file, produce descriptive statistics, and create a permanent SPSS data set.


beginning of sample command file
set width=80 highres=off
* Read data, set missing values for persinc
data list free file='income.data' / gender race persinc
missing values persinc (99)

* Produce descriptive statistics
descriptives var=all

* Save permanent SPSS system file
save outfile='income.sav'
end of sample command file
To run the program type

	% spss -m < income.spss >! income.lst
NOTE: Be sure you DO NOT use the same name for your command file (here income.spss) and the output file (here income.lst).

The results are written to the file

	income.lst
The permanent SPSS data set is stored in your current directory and is called

	income.sav

Reading from a permanent SPSS data set
This example reads data from the permanent SPSS data set created in the above example and performs a two-way ANOVA with the data. The name of the command file is

	anova.spss

beginning of sample command file
set width=80 highres=off

get file='income.sav'
anova persinc by gender(1,2) race(1,2) 
end of sample command file
To run this program type

	% spss -m < anova.spss >! anova.lst
NOTE: Be sure you DO NOT use the same name for your command file (here anova.spss) and the output file (here anova.lst).

The results will appear in the file

	anova.lst

For this example, the input data file, income.data is


    1 1 20
    1 1 99
    1 1 13
    2 1  1
    1 1 10
    2 2  5
    2 1 12
    1 1  7
    2 1 99
    2 2  2

University of Delaware
June 19, 1994