Differences between revisions 4 and 9 (spanning 5 versions)
Revision 4 as of 2020-06-16 17:13:57
Size: 2707
Comment:
Revision 9 as of 2021-11-12 22:20:24
Size: 2593
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
SPSS is capable of handling most file formats, including proprietary ones. But only god can help you if you use characters outside ANSI ASCII. SPSS is capable of handling most file formats, including proprietary ones.
Line 5: Line 5:
<<TableOfContents()>> <<TableOfContents>>
Line 61: Line 61:
For an explanation on the syntax used on the `/variables` subcommand, see [[SPSSDataImport|here]]. For an explanation on the syntax used on the `/variables` subcommand, see [[SPSS/ReadingData|here]].
Line 80: Line 80:
== Tab-Delimited == == Tab-delimited ==
Line 96: Line 96:
For an explanation on the syntax used on the `/variables` subcommand, see [[SPSSDataImport|here]]. For an explanation on the syntax used on the `/variables` subcommand, see [[SPSS/ReadingData|here]].
Line 133: Line 133:
It is necessary to declare all variables, their widths, and their types on import. If the file has column headers, update the `/firstcase` subcommand.
For an explanation on the syntax used on the `/variables` subcommand, see [[SPSS/ReadingData|here]].

SPSS File I/O

SPSS is capable of handling most file formats, including proprietary ones.


Excel

To import from an Excel spreadsheet:

get data
  /type=xlsx
  /file="path/to/file"
  /sheet=name "Sheet1"
  /cellrange=full
  /readnames=on
  /assumedstrwidth=32767.

To export into an Excel spreadsheet:

save translate
  /outfile="path/to/file"
  /type=xlsx
  /version=12
  /map
  /replace
  /fieldnames
  /cells=values
  /keep=VARLIST.

It is not possible to export into an existing spreadsheet and add a sheet.


CSV

To import from a CSV file:

get data
  /type=txt
  /file="path/to/file"
  /delimiters=","
  /firstcase=1
  /importcase=all
  /variables=
  VAR1 A1
  VAR2 F2.

For an explanation on the syntax used on the /variables subcommand, see here.

To export into a CSV file:

save translate
  /outfile="path/to/file"
  /type=csv
  /map
  /replace
  /fieldnames
  /cells=values
  /keep=VARLIST.


Tab-delimited

To import from a tab-delimited file:

get data
  /type=txt
  /file="path/to/file"
  /delimiters="\t"
  /firstcase=1
  /importcase=all
  /variables=
  VAR1 A1
  VAR2 F2.

For an explanation on the syntax used on the /variables subcommand, see here.

To export into a tab-delimited file:

save translate
  /outfile="path/to/file"
  /type=tab
  /map
  /replace
  /fieldnames
  /cells=values
  /keep=VARLIST.


Fixed-width

To import from a fixed-width file:

get data
  /type=txt
  /file="path/to/file"
  /arrangement=fixed
  /fixcase=1
  /firstcase=1
  /importcase=all
  /variables=
  /1
  VAR1 0-2 A
  VAR2 3-5 F.

For an explanation on the syntax used on the /variables subcommand, see here.

To export into a fixed-width file:

write outfile="path/to/file"
  /1 VARLIST.


Stata

Note that inter-operability of Stata and SPSS is locked to specific versions. SPSS 22 is inter-operable with Stata 8 only.

There must also be considerations for metadata loss--Stata 8 has very low limits on variable and value labels.

To import from a Stata file:

get stata file="path/to/file".

To export into a Stata 8 SE file:

save translate
  /outfile="path/to/file"
  /type=stata
  /version=8
  /edition=se
  /map
  /replace
  /keep=VARLIST.


CategoryRicottone

SPSS/FileIO (last edited 2021-11-24 15:33:10 by DominicRicottone)