Differences between revisions 1 and 9 (spanning 8 versions)
Revision 1 as of 2020-01-15 17:53:41
Size: 1569
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.

<<TableOfC
ontents>>
Line 53: Line 55:
  /importcase=all
Line 58: Line 61:
It is necessary to declare all variables and their formats on import. For an explanation on the syntax used on the `/variables` subcommand, see [[SPSS/ReadingData|here]].
Line 77: Line 80:
== Tab-Delimited == == Tab-delimited ==
Line 87: Line 90:
  /importcase=all
Line 92: Line 96:
It is necessary to declare all variables and their formats on import. For an explanation on the syntax used on the `/variables` subcommand, see [[SPSS/ReadingData|here]].
Line 107: Line 111:
----



== 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 [[SPSS/ReadingData|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.
}}}

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)