⇤ ← Revision 1 as of 2020-01-15 17:53:41
Size: 1569
Comment:
|
Size: 2760
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 53: | Line 53: |
/importcase=all | |
Line 58: | Line 59: |
It is necessary to declare all variables and their formats on import. | It is necessary to declare all variables and their formats on import. If the file has column headers, update the `/firstcase` subcommand. |
Line 87: | Line 88: |
/importcase=all | |
Line 92: | Line 94: |
It is necessary to declare all variables and their formats on import. | It is necessary to declare all variables and their formats on import. If the file has column headers, update the `/firstcase` subcommand. |
Line 107: | Line 109: |
---- == 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. }}} It is necessary to declare all variables, their widths, and their types on import. If the file has column headers, update the `/firstcase` subcommand. 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. But only god can help you if you use characters outside ANSI ASCII.
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.
It is necessary to declare all variables and their formats on import. If the file has column headers, update the /firstcase subcommand.
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.
It is necessary to declare all variables and their formats on import. If the file has column headers, update the /firstcase subcommand.
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.
It is necessary to declare all variables, their widths, and their types on import. If the file has column headers, update the /firstcase subcommand.
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.