1 @node System and Portable File IO
2 @chapter System and Portable File I/O
4 The commands in this chapter read, write, and examine system files and
8 * APPLY DICTIONARY:: Apply system file dictionary to active file.
9 * EXPORT:: Write to a portable file.
10 * GET:: Read from a system file.
11 * GET DATA:: Read from foreign files.
12 * IMPORT:: Read from a portable file.
13 * SAVE:: Write to a system file.
14 * SAVE TRANSLATE:: Write data in foreign file formats.
15 * SYSFILE INFO:: Display system file dictionary.
16 * XEXPORT:: Write to a portable file, as a transformation.
17 * XSAVE:: Write to a system file, as a transformation.
20 @node APPLY DICTIONARY
21 @section APPLY DICTIONARY
22 @vindex APPLY DICTIONARY
25 APPLY DICTIONARY FROM=@{'file-name',file_handle@}.
28 @cmd{APPLY DICTIONARY} applies the variable labels, value labels,
29 and missing values taken from a file to corresponding
30 variables in the active file. In some cases it also updates the
33 Specify a system file, portable file, or scratch file with a file name
34 string or as a file handle (@pxref{File Handles}). The dictionary in the
35 file will be read, but it will not replace the active file dictionary.
36 The file's data will not be read.
38 Only variables with names that exist in both the active file and the
39 system file are considered. Variables with the same name but different
40 types (numeric, string) will cause an error message. Otherwise, the
41 system file variables' attributes will replace those in their matching
42 active file variables:
46 If a system file variable has a variable label, then it will replace the
47 active file variable's variable label. If the system file variable does
48 not have a variable label, then the active file variable's variable
49 label, if any, will be retained.
52 If the system file variable has custom attributes (@pxref{VARIABLE
53 ATTRIBUTE}), then those attributes replace the active file variable's
54 custom attributes. If the system file variable does not have custom
55 attributes, then the active file variable's custom attributes, if any,
59 If the active file variable is numeric or short string, then value
60 labels and missing values, if any, will be copied to the active file
61 variable. If the system file variable does not have value labels or
62 missing values, then those in the active file variable, if any, will not
66 In addition to properties of variables, some properties of the active
67 file dictionary as a whole are updated:
71 If the system file has custom attributes (@pxref{DATAFILE ATTRIBUTE}),
72 then those attributes replace the active file variable's custom
76 If the active file has a weighting variable (@pxref{WEIGHT}), and the
77 system file does not, or if the weighting variable in the system file
78 does not exist in the active file, then the active file weighting
79 variable, if any, is retained. Otherwise, the weighting variable in
80 the system file becomes the active file weighting variable.
83 @cmd{APPLY DICTIONARY} takes effect immediately. It does not read the
85 file. The system file is not modified.
94 /UNSELECTED=@{RETAIN,DELETE@}
98 /RENAME=(src_names=target_names)@dots{}
103 The @cmd{EXPORT} procedure writes the active file dictionary and data to a
104 specified portable file or scratch file.
106 By default, cases excluded with FILTER are written to the
107 file. These can be excluded by specifying DELETE on the UNSELECTED
108 subcommand. Specifying RETAIN makes the default explicit.
110 Portable files express real numbers in base 30. Integers are always
111 expressed to the maximum precision needed to make them exact.
112 Non-integers are, by default, expressed to the machine's maximum
113 natural precision (approximately 15 decimal digits on many machines).
114 If many numbers require this many digits, the portable file may
115 significantly increase in size. As an alternative, the DIGITS
116 subcommand may be used to specify the number of decimal digits of
117 precision to write. DIGITS applies only to non-integers.
119 The OUTFILE subcommand, which is the only required subcommand, specifies
120 the portable file or scratch file to be written as a file name string or
121 a file handle (@pxref{File Handles}).
123 DROP, KEEP, and RENAME follow the same format as the SAVE procedure
126 The TYPE subcommand specifies the character set for use in the
127 portable file. Its value is currently not used.
129 The MAP subcommand is currently ignored.
131 @cmd{EXPORT} is a procedure. It causes the active file to be read.
139 /FILE=@{'file-name',file_handle@}
142 /RENAME=(src_names=target_names)@dots{}
145 @cmd{GET} clears the current dictionary and active file and
146 replaces them with the dictionary and data from a specified file.
148 The FILE subcommand is the only required subcommand. Specify the system
149 file, portable file, or scratch file to be read as a string file name or
150 a file handle (@pxref{File Handles}).
152 By default, all the variables in a file are read. The DROP
153 subcommand can be used to specify a list of variables that are not to be
154 read. By contrast, the KEEP subcommand can be used to specify variable
155 that are to be read, with all other variables not read.
157 Normally variables in a file retain the names that they were
158 saved under. Use the RENAME subcommand to change these names. Specify,
159 within parentheses, a list of variable names followed by an equals sign
160 (@samp{=}) and the names that they should be renamed to. Multiple
161 parenthesized groups of variable names can be included on a single
162 RENAME subcommand. Variables' names may be swapped using a RENAME
163 subcommand of the form @samp{/RENAME=(A B=B A)}.
165 Alternate syntax for the RENAME subcommand allows the parentheses to be
166 eliminated. When this is done, only a single variable may be renamed at
167 once. For instance, @samp{/RENAME=A=B}. This alternate syntax is
170 DROP, KEEP, and RENAME are executed in left-to-right order.
171 Each may be present any number of times. @cmd{GET} never modifies a
172 file on disk. Only the active file read from the file
173 is affected by these subcommands.
175 @cmd{GET} does not cause the data to be read, only the dictionary. The data
176 is read later, when a procedure is executed.
178 Use of @cmd{GET} to read a portable file or scratch file is a PSPP
187 /TYPE=@{GNM,PSQL,TXT@}
188 @dots{}additional subcommands depending on TYPE@dots{}
191 The @cmd{GET DATA} command is used to read files and other data sources
192 created by other applications.
193 When this command is executed, the current dictionary and active file are
194 replaced with variables and data read from the specified source.
196 The TYPE subcommand is mandatory and must be the first subcommand
197 specified. It determines the type of the file or source to read.
198 PSPP currently supports the following file types:
202 Spreadsheet files created by Gnumeric (@url{http://gnumeric.org}).
205 Relations from PostgreSQL databases (@url{http://postgresql.org}).
208 Textual data files in columnar and delimited formats.
211 Each supported file type has additional subcommands, explained in
212 separate sections below.
215 * GET DATA /TYPE=GNM::
216 * GET DATA /TYPE=PSQL::
217 * GET DATA /TYPE=TXT::
220 @node GET DATA /TYPE=GNM
221 @subsection Gnumeric Spreadsheet Files
225 /FILE=@{'file-name'@}
226 /SHEET=@{NAME 'sheet-name', INDEX n@}
227 /CELLRANGE=@{RANGE 'range', FULL@}
228 /READNAMES=@{ON, OFF@}
233 @cindex spreadsheet files
234 To use GET DATA to read a spreadsheet file created by Gnumeric
235 (@url{http://gnumeric.org}), specify TYPE=GNM to indicate the file's
236 format and use FILE to indicate the Gnumeric file to be read. All
237 other subcommands are optional.
239 The format of each variable is determined by the format of the spreadsheet
240 cell containing the first datum for the variable.
241 If this cell is of string (text) format, then the width of the variable is
242 determined from the length of the string it contains, unless the
243 ASSUMEDVARWIDTH subcommand is given.
246 The FILE subcommand is mandatory. Specify the name of the file
249 The SHEET subcommand specifies the sheet within the spreadsheet file to read.
250 There are two forms of the SHEET subcommand.
252 @samp{/SHEET=name @var{sheet-name}}, the string @var{sheet-name} is the
253 name of the sheet to read.
254 In the second form, @samp{/SHEET=index @var{idx}}, @var{idx} is a
255 integer which is the index of the sheet to read.
256 The first sheet has the index 1.
257 If the SHEET subcommand is omitted, then the command will read the
258 first sheet in the file.
260 The CELLRANGE subcommand specifies the range of cells within the sheet to read.
261 If the subcommand is given as @samp{/CELLRANGE=FULL}, then the entire
263 To read only part of a sheet, use the form
264 @samp{/CELLRANGE=range '@var{top-left-cell}:@var{bottom-right-cell}'}.
265 For example, the subcommand @samp{/CELLRANGE=range 'C3:P19'} reads
266 columns C--P, and rows 3--19 inclusive.
267 If no CELLRANGE subcommand is given, then the entire sheet is read.
269 If @samp{/READNAMES=ON} is specified, then the contents of cells of
270 the first row are used as the names of the variables in which to store
271 the data from subsequent rows.
272 If the READNAMES command is omitted, or if @samp{/READNAMES=OFF} is
273 used, then the variables receive automatically assigned names.
275 The ASSUMEDVARWIDTH subcommand specifies the maximum width of string
276 variables read from the file.
277 If omitted, the default value is determined from the length of the
278 string in the first spreadsheet cell for each variable.
281 @node GET DATA /TYPE=PSQL
282 @subsection Postgres Database Queries
286 /CONNECT=@{connection info@}
296 The PSQL type is used to import data from a postgres database server.
297 The server may be located locally or remotely.
298 Variables are automatically created based on the table column names
299 or the names specified in the SQL query.
300 Postgres data types of high precision, will loose precision when
302 Not all the postgres data types are able to be represented in PSPP.
303 If a datum cannot be represented a warning will be issued and that
304 datum will be set to SYSMIS.
306 The CONNECT subcommand is mandatory.
307 It is a string specifying the parameters of the database server from
308 which the data should be fetched.
309 The format of the string is given in the postgres manual
310 @url{http://www.postgresql.org/docs/8.0/static/libpq.html#LIBPQ-CONNECT}.
312 The SQL subcommand is mandatory.
313 It must be a valid SQL string to retrieve data from the database.
315 The ASSUMEDVARWIDTH subcommand specifies the maximum width of string
316 variables read from the database.
317 If omitted, the default value is determined from the length of the
318 string in the first value read for each variable.
320 The UNENCRYPTED subcommand allows data to be retrieved over an insecure
322 If the connection is not encrypted, and the UNENCRYPTED subcommand is not
323 given, then an error will occur.
324 Whether or not the connection is
325 encrypted depends upon the underlying psql library and the
326 capabilities of the database server.
328 The BSIZE subcommand serves only to optimise the speed of data transfer.
329 It specifies an upper limit on
330 number of cases to fetch from the database at once.
331 The default value is 4096.
332 If your SQL statement fetches a large number of cases but only a small number of
333 variables, then the data transfer may be faster if you increase this value.
334 Conversely, if the number of variables is large, or if the machine on which
335 PSPP is running has only a
336 small amount of memory, then a smaller value will be better.
339 The following syntax is an example:
342 /CONNECT='host=example.com port=5432 dbname=product user=fred passwd=xxxx'
343 /SQL='select * from manufacturer'.
347 @node GET DATA /TYPE=TXT
348 @subsection Textual Data Files
352 /FILE=@{'file-name',file_handle@}
353 [/ARRANGEMENT=@{DELIMITED,FIXED@}]
354 [/FIRSTCASE=@{first_case@}]
355 [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
356 @dots{}additional subcommands depending on ARRANGEMENT@dots{}
361 When TYPE=TXT is specified, GET DATA reads data in a delimited or
362 fixed columnar format, much like DATA LIST (@pxref{DATA LIST}).
364 The FILE subcommand is mandatory. Specify the file to be read as
365 a string file name or (for textual data
366 only) a file handle (@pxref{File Handles}).
368 The ARRANGEMENT subcommand determines the file's basic format.
369 DELIMITED, the default setting, specifies that fields in the input
370 data are separated by spaces, tabs, or other user-specified
371 delimiters. FIXED specifies that fields in the input data appear at
372 particular fixed column positions within records of a case.
374 By default, cases are read from the input file starting from the first
375 line. To skip lines at the beginning of an input file, set FIRSTCASE
376 to the number of the first line to read: 2 to skip the first line, 3
377 to skip the first two lines, and so on.
379 IMPORTCASE can be used to limit the number of cases read from the
380 input file. With the default setting, ALL, all cases in the file are
381 read. Specify FIRST @i{max_cases} to read at most @i{max_cases} cases
382 from the file. Use PERCENT @i{percent} to read only @i{percent}
383 percent, approximately, of the cases contained in the file. (The
384 percentage is approximate, because there is no way to accurately count
385 the number of cases in the file without reading the entire file. The
386 number of cases in some kinds of unusual files cannot be estimated;
387 PSPP will read all cases in such files.)
389 FIRSTCASE and IMPORTCASE may be used with delimited and fixed-format
390 data. The remaining subcommands, which apply only to one of the two file
391 arrangements, are described below.
394 * GET DATA /TYPE=TXT /ARRANGEMENT=DELIMITED::
395 * GET DATA /TYPE=TXT /ARRANGEMENT=FIXED::
398 @node GET DATA /TYPE=TXT /ARRANGEMENT=DELIMITED
399 @subsubsection Reading Delimited Data
403 /FILE=@{'file-name',file_handle@}
404 [/ARRANGEMENT=@{DELIMITED,FIXED@}]
405 [/FIRSTCASE=@{first_case@}]
406 [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
408 /DELIMITERS="delimiters"
409 [/QUALIFIER="quotes" [/ESCAPE]]
410 [/DELCASE=@{LINE,VARIABLES n_variables@}]
411 /VARIABLES=del_var [del_var]@dots{}
412 where each del_var takes the form:
416 The GET DATA command with TYPE=TXT and ARRANGEMENT=DELIMITED reads
417 input data from text files in delimited format, where fields are
418 separated by a set of user-specified delimiters. Its capabilities are
419 similar to those of DATA LIST FREE (@pxref{DATA LIST FREE}), with a
422 The required FILE subcommand and optional FIRSTCASE and IMPORTCASE
423 subcommands are described above (@pxref{GET DATA /TYPE=TXT}).
425 DELIMITERS, which is required, specifies the set of characters that
426 may separate fields. Each character in the string specified on
427 DELIMITERS separates one field from the next. The end of a line also
428 separates fields, regardless of DELIMITERS. Two consecutive
429 delimiters in the input yield an empty field, as does a delimiter at
430 the end of a line. A space character as a delimiter is an exception:
431 consecutive spaces do not yield an empty field and neither does any
432 number of spaces at the end of a line.
434 To use a tab as a delimiter, specify @samp{\t} at the beginning of the
435 DELIMITERS string. To use a backslash as a delimiter, specify
436 @samp{\\} as the first delimiter or, if a tab should also be a
437 delimiter, immediately following @samp{\t}. To read a data file in
438 which each field appears on a separate line, specify the empty string
441 The optional QUALIFIER subcommand names one or more characters that
442 can be used to quote values within fields in the input. A field that
443 begins with one of the specified quote characters ends at the next
444 matching quote. Intervening delimiters become part of the field,
445 instead of terminating it. The ability to specify more than one quote
446 character is a PSPP extension.
448 By default, a character specified on QUALIFIER cannot itself be
449 embedded within a field that it quotes, because the quote character
450 always terminates the quoted field. With ESCAPE, however, a doubled
451 quote character within a quoted field inserts a single instance of the
452 quote into the field. For example, if @samp{'} is specified on
453 QUALIFIER, then without ESCAPE @code{'a''b'} specifies a pair of
454 fields that contain @samp{a} and @samp{b}, but with ESCAPE it
455 specifies a single field that contains @samp{a'b}. ESCAPE is a PSPP
458 The DELCASE subcommand controls how data may be broken across lines in
459 the data file. With LINE, the default setting, each line must contain
460 all the data for exactly one case. For additional flexibility, to
461 allow a single case to be split among lines or multiple cases to be
462 contained on a single line, specify VARIABLES @i{n_variables}, where
463 @i{n_variables} is the number of variables per case.
465 The VARIABLES subcommand is required and must be the last subcommand.
466 Specify the name of each variable and its input format (@pxref{Input
467 and Output Formats}) in the order they should be read from the input
470 @subsubheading Examples
473 On a Unix-like system, the @samp{/etc/passwd} file has a format
477 root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash
478 blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash
479 john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash
480 jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh
484 The following syntax reads a file in the format used by
487 @c If you change this example, change the regression test in
488 @c tests/language/data-io/get-data.at to match.
490 GET DATA /TYPE=TXT /FILE='/etc/passwd' /DELIMITERS=':'
491 /VARIABLES=username A20
501 Consider the following data on used cars:
504 model year mileage price type age
505 Civic 2002 29883 15900 Si 2
506 Civic 2003 13415 15900 EX 1
507 Civic 1992 107000 3800 n/a 12
508 Accord 2002 26613 17900 EX 1
512 The following syntax can be used to read the used car data:
514 @c If you change this example, change the regression test in
515 @c tests/language/data-io/get-data.at to match.
517 GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2
527 Consider the following information on animals in a pet store:
530 'Pet''s Name', "Age", "Color", "Date Received", "Price", "Height", "Type"
531 , (Years), , , (Dollars), ,
532 "Rover", 4.5, Brown, "12 Feb 2004", 80, '1''4"', "Dog"
533 "Charlie", , Gold, "5 Apr 2007", 12.3, "3""", "Fish"
534 "Molly", 2, Black, "12 Dec 2006", 25, '5"', "Cat"
535 "Gilly", , White, "10 Apr 2007", 10, "3""", "Guinea Pig"
539 The following syntax can be used to read the pet store data:
541 @c If you change this example, change the regression test in
542 @c tests/language/data-io/get-data.at to match.
544 GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='''"' /ESCAPE
555 @node GET DATA /TYPE=TXT /ARRANGEMENT=FIXED
556 @subsubsection Reading Fixed Columnar Data
560 /FILE=@{'file-name',file_handle@}
561 [/ARRANGEMENT=@{DELIMITED,FIXED@}]
562 [/FIRSTCASE=@{first_case@}]
563 [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
566 /VARIABLES fixed_var [fixed_var]@dots{}
567 [/rec# fixed_var [fixed_var]@dots{}]@dots{}
568 where each fixed_var takes the form:
569 variable start-end format
572 The GET DATA command with TYPE=TXT and ARRANGEMENT=FIXED reads input
573 data from text files in fixed format, where each field is located in
574 particular fixed column positions within records of a case. Its
575 capabilities are similar to those of DATA LIST FIXED (@pxref{DATA LIST
576 FIXED}), with a few enhancements.
578 The required FILE subcommand and optional FIRSTCASE and IMPORTCASE
579 subcommands are described above (@pxref{GET DATA /TYPE=TXT}).
581 The optional FIXCASE subcommand may be used to specify the positive
582 integer number of input lines that make up each case. The default
585 The VARIABLES subcommand, which is required, specifies the positions
586 at which each variable can be found. For each variable, specify its
587 name, followed by its start and end column separated by @samp{-}
588 (e.g.@: @samp{0-9}), followed by the input format type (e.g.@:
589 @samp{F}). For this command, columns are numbered starting from 0 at
590 the left column. Introduce the variables in the second and later
591 lines of a case by a slash followed by the number of the line within
592 the case, e.g.@: @samp{/2} for the second line.
594 @subsubheading Examples
597 Consider the following data on used cars:
600 model year mileage price type age
601 Civic 2002 29883 15900 Si 2
602 Civic 2003 13415 15900 EX 1
603 Civic 1992 107000 3800 n/a 12
604 Accord 2002 26613 17900 EX 1
608 The following syntax can be used to read the used car data:
610 @c If you change this example, change the regression test in
611 @c tests/language/data-io/get-data.at to match.
613 GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2
614 /VARIABLES=model 0-7 A
632 /RENAME=(src_names=target_names)@dots{}
635 The @cmd{IMPORT} transformation clears the active file dictionary and
637 replaces them with a dictionary and data from a system, portable file,
640 The FILE subcommand, which is the only required subcommand, specifies
641 the portable file to be read as a file name string or a file handle
642 (@pxref{File Handles}).
644 The TYPE subcommand is currently not used.
646 DROP, KEEP, and RENAME follow the syntax used by @cmd{GET} (@pxref{GET}).
648 @cmd{IMPORT} does not cause the data to be read, only the dictionary. The
649 data is read later, when a procedure is executed.
651 Use of @cmd{IMPORT} to read a system file or scratch file is a PSPP
660 /OUTFILE=@{'file-name',file_handle@}
661 /UNSELECTED=@{RETAIN,DELETE@}
662 /@{COMPRESSED,UNCOMPRESSED@}
663 /PERMISSIONS=@{WRITEABLE,READONLY@}
667 /RENAME=(src_names=target_names)@dots{}
672 The @cmd{SAVE} procedure causes the dictionary and data in the active
674 be written to a system file or scratch file.
676 OUTFILE is the only required subcommand. Specify the system file or
677 scratch file to be written as a string file name or a file handle
678 (@pxref{File Handles}).
680 By default, cases excluded with FILTER are written to the system file.
681 These can be excluded by specifying DELETE on the UNSELECTED
682 subcommand. Specifying RETAIN makes the default explicit.
684 The COMPRESS and UNCOMPRESS subcommand determine whether the saved
685 system file is compressed. By default, system files are compressed.
686 This default can be changed with the SET command (@pxref{SET}).
688 The PERMISSIONS subcommand specifies permissions for the new system
689 file. WRITEABLE, the default, creates the file with read and write
690 permission. READONLY creates the file for read-only access.
692 By default, all the variables in the active file dictionary are written
693 to the system file. The DROP subcommand can be used to specify a list
694 of variables not to be written. In contrast, KEEP specifies variables
695 to be written, with all variables not specified not written.
697 Normally variables are saved to a system file under the same names they
698 have in the active file. Use the RENAME subcommand to change these names.
699 Specify, within parentheses, a list of variable names followed by an
700 equals sign (@samp{=}) and the names that they should be renamed to.
701 Multiple parenthesized groups of variable names can be included on a
702 single RENAME subcommand. Variables' names may be swapped using a
703 RENAME subcommand of the form @samp{/RENAME=(A B=B A)}.
705 Alternate syntax for the RENAME subcommand allows the parentheses to be
706 eliminated. When this is done, only a single variable may be renamed at
707 once. For instance, @samp{/RENAME=A=B}. This alternate syntax is
710 DROP, KEEP, and RENAME are performed in left-to-right order. They
711 each may be present any number of times. @cmd{SAVE} never modifies
712 the active file. DROP, KEEP, and RENAME only affect the system file
715 The VERSION subcommand specifies the version of the file format. Valid
716 versions are 2 and 3. The default version is 3. In version 2 system
717 files, variable names longer than 8 bytes will be truncated. The two
718 versions are otherwise identical.
720 The NAMES and MAP subcommands are currently ignored.
722 @cmd{SAVE} causes the data to be read. It is a procedure.
725 @section SAVE TRANSLATE
726 @vindex SAVE TRANSLATE
730 /OUTFILE=@{'file-name',file_handle@}
733 [/MISSING=@{IGNORE,RECODE@}]
737 [/RENAME=(src_names=target_names)@dots{}]
738 [/UNSELECTED=@{RETAIN,DELETE@}]
741 @dots{}additional subcommands depending on TYPE@dots{}
744 The @cmd{SAVE TRANSLATE} command is used to save data into various
745 formats understood by other applications.
747 The OUTFILE and TYPE subcommands are mandatory. OUTFILE specifies the
748 file to be written, as a string file name or a file handle
749 (@pxref{File Handles}). TYPE determines the type of the file or
750 source to read. It must be one of the following:
754 Comma-separated value format,
757 Tab-delimited format.
760 By default, SAVE TRANSLATE will not overwrite an existing file. Use
761 REPLACE to force an existing file to be overwritten.
763 With MISSING=IGNORE, the default, SAVE TRANSLATE treats user-missing
764 values as if they were not missing. Specify MISSING=RECODE to output
765 numeric user-missing values like system-missing values and string
766 user-missing values as all spaces.
768 By default, all the variables in the active file dictionary are saved
769 to the system file, but DROP or KEEP can select a subset of variable
770 to save. The RENAME subcommand can also be used to change the names
771 under which variables are saved. UNSELECTED determines whether cases
772 filtered out by the FILTER command are written to the output file.
773 These subcommands have the same syntax and meaning as on the
774 @cmd{SAVE} command (@pxref{SAVE}).
776 Each supported file type has additional subcommands, explained in
777 separate sections below.
779 @cmd{SAVE TRANSLATE} causes the data to be read. It is a procedure.
782 * SAVE TRANSLATE /TYPE=CSV and TYPE=TAB::
785 @node SAVE TRANSLATE /TYPE=CSV and TYPE=TAB
786 @subsection Writing Comma- and Tab-Separated Data Files
790 /OUTFILE=@{'file-name',file_handle@}
793 [/MISSING=@{IGNORE,RECODE@}]
797 [/RENAME=(src_names=target_names)@dots{}]
798 [/UNSELECTED=@{RETAIN,DELETE@}]
801 [/CELLS=@{VALUES,LABELS@}]
802 [/TEXTOPTIONS DELIMITER='delimiter']
803 [/TEXTOPTIONS QUALIFIER='qualifier']
804 [/TEXTOPTIONS DECIMAL=@{DOT,COMMA@}]
805 [/TEXTOPTIONS FORMAT=@{PLAIN,VARIABLE@}]
808 The SAVE TRANSLATE command with TYPE=CSV or TYPE=TAB writes data in a
809 comma- or tab-separated value format similar to that described by
810 RFC@tie{}4180. Each variable becomes one output column, and each case
811 becomes one line of output. If FIELDNAMES is specified, an additional
812 line at the top of the output file lists variable names.
814 The CELLS and TEXTOPTIONS FORMAT settings determine how values are
815 written to the output file:
818 @item CELLS=VALUES FORMAT=PLAIN (the default settings)
819 Writes variables to the output in ``plain'' formats that ignore the
820 details of variable formats. Numeric values are written as plain
821 decimal numbers with enough digits to indicate their exact values in
822 machine representation. Numeric values include @samp{e} followed by
823 an exponent if the exponent value would be less than -4 or greater
824 than 16. Dates are written in MM/DD/YYYY format and times in HH:MM:SS
825 format. WKDAY and MONTH values are written as decimal numbers.
827 Numeric values use, by default, the decimal point character set with
828 SET DECIMAL (@pxref{SET DECIMAL}). Use DECIMAL=DOT or DECIMAL=COMMA
829 to force a particular decimal point character.
831 @item CELLS=VALUES FORMAT=VARIABLE
832 Writes variables using their print formats. Leading and trailing
833 spaces are removed from numeric values, and trailing spaces are
834 removed from string values.
836 @item CELLS=LABEL FORMAT=PLAIN
837 @itemx CELLS=LABEL FORMAT=VARIABLE
838 Writes value labels where they exist, and otherwise writes the values
839 themselves as described above.
842 Regardless of CELLS and TEXTOPTIONS FORMAT, numeric system-missing
843 values are output as a single space.
845 For TYPE=TAB, tab characters delimit values. For TYPE=CSV, the
846 TEXTOPTIONS DELIMITER and DECIMAL settings determine the character
847 that separate values within a line. If DELIMITER is specified, then
848 the specified string separate values. If DELIMITER is not specified,
849 then the default is a comma with DECIMAL=DOT or a semicolon with
850 DECIMAL=COMMA. If DECIMAL is not given either, it is implied by the
851 decimal point character set with SET DECIMAL (@pxref{SET DECIMAL}).
853 The TEXTOPTIONS QUALIFIER setting specifies a character that is output
854 before and after a value that contains the delimiter character or the
855 qualifier character. The default is a double quote (@samp{@@}). A
856 qualifier character that appears within a value is doubled.
859 @section SYSFILE INFO
863 SYSFILE INFO FILE='file-name'.
866 @cmd{SYSFILE INFO} reads the dictionary in a system file and
867 displays the information in its dictionary.
869 Specify a file name or file handle. @cmd{SYSFILE INFO} reads that file as
870 a system file and displays information on its dictionary.
872 @cmd{SYSFILE INFO} does not affect the current active file.
884 /RENAME=(src_names=target_names)@dots{}
889 The @cmd{EXPORT} transformation writes the active file dictionary and
890 data to a specified portable file.
892 This transformation is a PSPP extension.
894 It is similar to the @cmd{EXPORT} procedure, with two differences:
898 @cmd{XEXPORT} is a transformation, not a procedure. It is executed when
899 the data is read by a procedure or procedure-like command.
902 @cmd{XEXPORT} does not support the UNSELECTED subcommand.
905 @xref{EXPORT}, for more information.
914 /@{COMPRESSED,UNCOMPRESSED@}
915 /PERMISSIONS=@{WRITEABLE,READONLY@}
919 /RENAME=(src_names=target_names)@dots{}
924 The @cmd{XSAVE} transformation writes the active file dictionary and
925 data to a system file or scratch file. It is similar to the @cmd{SAVE}
926 procedure, with two differences:
930 @cmd{XSAVE} is a transformation, not a procedure. It is executed when
931 the data is read by a procedure or procedure-like command.
934 @cmd{XSAVE} does not support the UNSELECTED subcommand.
937 @xref{SAVE}, for more information.