File Exchange

image thumbnail


version 1.0 (5.91 KB) by

saves numerical matrices as ASCII data + SPSS import syntax



No License

save4spss()opens dialogue boxes to select a matrix,a cell array with variable names (optional),and specify a file name to save the matrix the SPSS syntax gets the same name.

save4spss(DATA,VARNAMES,FILE) saves the matrix DATA in the file given in FILE and creates a SPSS syntax file FILE.sps to import these data in SPSS .Variables (data columns) are named according to the elements of cell array VARNAMES.
After running save4spss, just open the generated SPSS syntax in SPSS and run it. Also see help save4spss

mystudy=[1 30 10000; 2 35 15000];
creates an ASCII file mystudy.dat and a SPSS syntax mystudy.sps.

If you run this syntax in SPSS the data are imported, the variables named and the file is saved as mystudy.sav

Comments and Ratings (4)


Just a follow up that the data will import using the GUI (type "save4spss()") however the first column is blank, everything is shifted over by one.

Martin Groen


Casper (view profile)

Does not work for large datasets.

Daniel Goerke

I'm wondering about this error message when executing the sav skript in SPSS:

>Fehler Nr. 105. Befehlsname: SAVE
>Dieser Befehl ist nicht gültig, bevor eine Arbeitsdatei definiert wurde.
>Dieser Befehl wird nicht ausgeführt.

in english:
>Error # 105. Command name: SAVE
>This command is not valid before a working file has been defined.
>Execution of this command stops.

I'm using PASW Statistics 18 and Matlab R2009b.
I edited the sav skript generated by save4spss() by adding the file path. The new data set created by the sav skript is empty.
Any ideas?

Best regards,


summary sentence incomplete

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today