Implement GET DATA/TYPE=TXT.
[pspp-builds.git] / doc / files.texi
1 @node System and Portable Files
2 @chapter System Files and Portable Files
3
4 The commands in this chapter read, write, and examine system files and
5 portable files.
6
7 @menu
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 * MATCH FILES::                 Merge system files.
14 * SAVE::                        Write to a system file.
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.
18 @end menu
19
20 @node APPLY DICTIONARY
21 @section APPLY DICTIONARY
22 @vindex APPLY DICTIONARY
23
24 @display
25 APPLY DICTIONARY FROM=@{'file-name',file_handle@}.
26 @end display
27
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
31 weighting variable.
32
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.
37
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, as described below.
43
44 If a system file variable has a variable label, then it will replace the
45 active file variable's variable label.  If the system file variable does
46 not have a variable label, then the active file variable's variable
47 label, if any, will be retained.
48
49 If the active file variable is numeric or short string, then value
50 labels and missing values, if any, will be copied to the active file
51 variable.  If the system file variable does not have value labels or
52 missing values, then those in the active file variable, if any, will not
53 be disturbed.
54
55 Finally, weighting of the active file is updated (@pxref{WEIGHT}).  If
56 the active file has a weighting variable, and the system file does not,
57 or if the weighting variable in the system file does not exist in the
58 active file, then the active file weighting variable, if any, is
59 retained.  Otherwise, the weighting variable in the system file becomes
60 the active file weighting variable.
61
62 @cmd{APPLY DICTIONARY} takes effect immediately.  It does not read the
63 active
64 file.  The system file is not modified.
65
66 @node EXPORT
67 @section EXPORT
68 @vindex EXPORT
69
70 @display
71 EXPORT
72         /OUTFILE='file-name'
73         /UNSELECTED=@{RETAIN,DELETE@}
74         /DIGITS=n
75         /DROP=var_list
76         /KEEP=var_list
77         /RENAME=(src_names=target_names)@dots{}
78         /TYPE=@{COMM,TAPE@}
79         /MAP
80 @end display
81
82 The @cmd{EXPORT} procedure writes the active file dictionary and data to a
83 specified portable file or scratch file.
84
85 By default, cases excluded with FILTER are written to the
86 file.  These can be excluded by specifying DELETE on the UNSELECTED
87 subcommand.  Specifying RETAIN makes the default explicit.
88
89 Portable files express real numbers in base 30.  Integers are always
90 expressed to the maximum precision needed to make them exact.
91 Non-integers are, by default, expressed to the machine's maximum
92 natural precision (approximately 15 decimal digits on many machines).
93 If many numbers require this many digits, the portable file may
94 significantly increase in size.  As an alternative, the DIGITS
95 subcommand may be used to specify the number of decimal digits of
96 precision to write.  DIGITS applies only to non-integers.
97
98 The OUTFILE subcommand, which is the only required subcommand, specifies
99 the portable file or scratch file to be written as a file name string or
100 a file handle (@pxref{File Handles}).
101
102 DROP, KEEP, and RENAME follow the same format as the SAVE procedure
103 (@pxref{SAVE}).
104
105 The TYPE subcommand specifies the character set for use in the
106 portable file.  Its value is currently not used.
107
108 The MAP subcommand is currently ignored.
109
110 @cmd{EXPORT} is a procedure.  It causes the active file to be read.
111
112 @node GET
113 @section GET
114 @vindex GET
115
116 @display
117 GET
118         /FILE=@{'file-name',file_handle@}
119         /DROP=var_list
120         /KEEP=var_list
121         /RENAME=(src_names=target_names)@dots{}
122 @end display
123
124 @cmd{GET} clears the current dictionary and active file and
125 replaces them with the dictionary and data from a specified file.
126
127 The FILE subcommand is the only required subcommand.  Specify the system
128 file, portable file, or scratch file to be read as a string file name or
129 a file handle (@pxref{File Handles}).
130
131 By default, all the variables in a file are read.  The DROP
132 subcommand can be used to specify a list of variables that are not to be
133 read.  By contrast, the KEEP subcommand can be used to specify variable
134 that are to be read, with all other variables not read.
135
136 Normally variables in a file retain the names that they were
137 saved under.  Use the RENAME subcommand to change these names.  Specify,
138 within parentheses, a list of variable names followed by an equals sign
139 (@samp{=}) and the names that they should be renamed to.  Multiple
140 parenthesized groups of variable names can be included on a single
141 RENAME subcommand.  Variables' names may be swapped using a RENAME
142 subcommand of the form @samp{/RENAME=(A B=B A)}.
143
144 Alternate syntax for the RENAME subcommand allows the parentheses to be
145 eliminated.  When this is done, only a single variable may be renamed at
146 once.  For instance, @samp{/RENAME=A=B}.  This alternate syntax is
147 deprecated.
148
149 DROP, KEEP, and RENAME are executed in left-to-right order.  
150 Each may be present any number of times.  @cmd{GET} never modifies a
151 file on disk.  Only the active file read from the file
152 is affected by these subcommands.
153
154 @cmd{GET} does not cause the data to be read, only the dictionary.  The data
155 is read later, when a procedure is executed.
156
157 Use of @cmd{GET} to read a portable file or scratch file is a PSPP
158 extension.
159
160 @node GET DATA
161 @section GET DATA
162 @vindex GET DATA
163
164 @display
165 GET DATA
166         /TYPE=@{GNM,TXT@}
167         /FILE=@{'file-name',file_handle@}
168         @dots{}additional subcommands depending on TYPE@dots{}
169 @end display
170
171 The @cmd{GET DATA} command is used to read files and other data sources 
172 created by other applications. 
173 When this command is executed, the current dictionary and active file are
174 replaced  with variables and data read from the specified source.
175
176 The TYPE subcommand is mandatory and must be the first subcommand
177 specified.  It determines the type of the file or source to read.
178 PSPP currently supports the following file types:
179
180 @table @asis
181 @item GNM
182 Spreadsheet files created by Gnumeric (@url{http://gnumeric.org}).
183
184 @item TXT
185 Textual data files in columnar and delimited formats.
186 @end table
187
188 The FILE subcommand is mandatory for all implemented file types.
189 Specify the file to be read as a string file name or (for textual data
190 only) a file handle (@pxref{File Handles}).
191
192 Each supported file type has additional subcommands, explained in
193 separate sections below.
194
195 @menu
196 * GET DATA /TYPE=GNM::
197 * GET DATA /TYPE=TXT::
198 @end menu
199
200 @node GET DATA /TYPE=GNM
201 @subsection Gnumeric Spreadsheet Files
202
203 @display
204 GET DATA /TYPE=GNM
205         /FILE=@{'file-name'@}
206         /SHEET=@{NAME 'sheet-name', INDEX n@}
207         /CELLRANGE=@{RANGE 'range', FULL@}
208         /READNAMES=@{ON, OFF@}
209         /ASSUMEDVARWIDTH=n.
210 @end display
211
212 @cindex Gnumeric
213 @cindex spreadsheet files
214 To use GET DATA to read a spreadsheet file created by Gnumeric
215 (@url{http://gnumeric.org}), specify TYPE=GNM to indicate the file's
216 format and use FILE to indicate the Gnumeric file to be read.  All
217 other subcommands are optional.
218
219 The format of each variable is determined by the format of the spreadsheet 
220 cell containing the first datum for the variable.
221 If this cell is of string (text) format, then the width of the variable is
222 determined from the length of the string it contains, unless the 
223 ASSUMEDVARWIDTH subcommand is given.
224
225 The SHEET subcommand specifies the sheet within the spreadsheet file to read.
226 There are two forms of the SHEET subcommand.
227 In the first form,
228 @samp{/SHEET=name @var{sheet-name}}, the string @var{sheet-name} is the
229 name of the sheet to read.
230 In the second form, @samp{/SHEET=index @var{idx}}, @var{idx} is a
231 integer which is the index of the sheet to read.
232 The first sheet has the index 1.
233 If the SHEET subcommand is omitted, then the command will read the
234 first sheet in the file.
235
236 The CELLRANGE subcommand specifies the range of cells within the sheet to read.
237 If the subcommand is given as @samp{/CELLRANGE=FULL}, then the entire
238 sheet  is read.
239 To read only part of a sheet, use the form 
240 @samp{/CELLRANGE=range '@var{top-left-cell}:@var{bottom-right-cell}'}.
241 For example, the subcommand @samp{/CELLRANGE=range 'C3:P19'} reads 
242 columns C--P, and rows 3--19 inclusive.
243 If no CELLRANGE subcommand is given, then the entire sheet is read.
244
245 If @samp{/READNAMES=ON} is specified, then the contents of cells of
246 the first row are used as the names of the variables in which to store
247 the data from subsequent rows. 
248 If the READNAMES command is omitted, or if @samp{/READNAMES=OFF} is
249 used, then the variables  receive automatically assigned names.
250
251 The ASSUMEDVARWIDTH subcommand specifies the maximum width of string
252 variables read  from the file.
253 If omitted, the default value is determined from the length of the 
254 string in the first spreadsheet cell for each variable.
255
256 @node GET DATA /TYPE=TXT
257 @subsection Textual Data Files
258
259 @display
260 GET DATA /TYPE=TXT
261         /FILE=@{'file-name',file_handle@}
262         [/ARRANGEMENT=@{DELIMITED,FIXED@}]
263         [/FIRSTCASE=@{first_case@}]
264         [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
265         @dots{}additional subcommands depending on ARRANGEMENT@dots{}
266 @end display
267
268 @cindex text files
269 @cindex data files
270 When TYPE=TXT is specified, GET DATA reads data in a delimited or
271 fixed columnar format, much like DATA LIST (@pxref{DATA LIST}).  The
272 FILE subcommand must be specified indicate the name or the file handle
273 of the file to be read.
274
275 The ARRANGEMENT subcommand determines the file's basic format.
276 DELIMITED, the default setting, specifies that fields in the input
277 data are separated by spaces, tabs, or other user-specified
278 delimiters.  FIXED specifies that fields in the input data appear at
279 particular fixed column positions within records of a case.
280
281 By default, cases are read from the input file starting from the first
282 line.  To skip lines at the beginning of an input file, set FIRSTCASE
283 to the number of the first line to read: 2 to skip the first line, 3
284 to skip the first two lines, and so on.
285
286 IMPORTCASE can be used to limit the number of cases read from the
287 input file.  With the default setting, ALL, all cases in the file are
288 read.  Specify FIRST @i{max_cases} to read at most @i{max_cases} cases
289 from the file.  Use PERCENT @i{percent} to read only @i{percent}
290 percent, approximately, of the cases contained in the file.  (The
291 percentage is approximate, because there is no way to accurately count
292 the number of cases in the file without reading the entire file.  The
293 number of cases in some kinds of unusual files cannot be estimated;
294 PSPP will read all cases in such files.)
295
296 FIRSTCASE and IMPORTCASE may be used with delimited and fixed-format
297 data.  The remaining subcommands, which apply only to one of the two  file
298 arrangements, are described below.
299
300 @menu
301 * GET DATA /TYPE=TXT /ARRANGEMENT=DELIMITED::
302 * GET DATA /TYPE=TXT /ARRANGEMENT=FIXED::
303 @end menu
304
305 @node GET DATA /TYPE=TXT /ARRANGEMENT=DELIMITED
306 @subsubsection Reading Delimited Data
307
308 @display
309 GET DATA /TYPE=TXT
310         /FILE=@{'file-name',file_handle@}
311         [/ARRANGEMENT=@{DELIMITED,FIXED@}]
312         [/FIRSTCASE=@{first_case@}]
313         [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
314
315         /DELIMITERS="delimiters"
316         [/QUALIFIER="quote"]
317         [/DELCASE=@{LINE,VARIABLES n_variables@}]
318         /VARIABLES=del_var [del_var]@dots{}
319 where each del_var takes the form:
320         variable format
321 @end display
322
323 The GET DATA command with TYPE=TXT and ARRANGEMENT=DELIMITED reads
324 input data from text files in delimited format, where fields are
325 separated by a set of user-specified delimiters.  Its capabilities are
326 similar to those of DATA LIST FREE (@pxref{DATA LIST FREE}), with a
327 few enhancements.
328
329 The required FILE subcommand and optional FIRSTCASE and IMPORTCASE
330 subcommands are described above (@pxref{GET DATA /TYPE=TXT}).
331
332 DELIMITERS, which is required, specifies the set of characters that
333 may separate fields.  Each character in the string specified on
334 DELIMITERS separates one field from the next.  The end of a line also
335 separates fields, regardless of DELIMITERS.  Two consecutive
336 delimiters in the input yield an empty field, as does a delimiter at
337 the end of a line.  A space character as a delimiter is an exception:
338 consecutive spaces do not yield an empty field and neither does any
339 number of spaces at the end of a line.
340
341 To use a tab as a delimiter, specify @samp{\t} at the beginning of the
342 DELIMITERS string.  To use a backslash as a delimiter, specify
343 @samp{\\} as the first delimiter or, if a tab should also be a
344 delimiter, immediately following @samp{\t}.  To read a data file in
345 which each field appears on a separate line, specify the empty string
346 for DELIMITERS.
347
348 The optional QUALIFIER subcommand names a character that can be used
349 to quote values within fields in the input.  A field that begins with
350 the specified quote character ends at the next match quote.
351 Intervening delimiters become part of the field, instead of
352 terminating it.
353
354 The DELCASE subcommand controls how data may be broken across lines in
355 the data file.  With LINE, the default setting, each line must contain
356 all the data for exactly one case.  For additional flexibility, to
357 allow a single case to be split among lines or multiple cases to be
358 contained on a single line, specify VARIABLES @i{n_variables}, where
359 @i{n_variables} is the number of variables per case.
360
361 The VARIABLES subcommand is required and must be the last subcommand.
362 Specify the name of each variable and its input format (@pxref{Input
363 and Output Formats}) in the order they should be read from the input
364 file.
365
366 @subsubheading Examples
367
368 @noindent
369 On a Unix-like system, the @samp{/etc/passwd} file has a format
370 similar to this:
371
372 @example
373 root:$1$nyeSP5gD$pDq/:0:0:,,,:/root:/bin/bash
374 blp:$1$BrP/pFg4$g7OG:1000:1000:Ben Pfaff,,,:/home/blp:/bin/bash
375 john:$1$JBuq/Fioq$g4A:1001:1001:John Darrington,,,:/home/john:/bin/bash
376 jhs:$1$D3li4hPL$88X1:1002:1002:Jason Stover,,,:/home/jhs:/bin/csh
377 @end example
378
379 @noindent
380 The following syntax reads a file in the format used by
381 @samp{/etc/passwd}:
382
383 @c If you change this example, change the regression test in
384 @c tests/command/get-data-txt-examples.sh to match.
385 @example
386 GET DATA /TYPE=TXT /FILE='/etc/passwd' /DELIMITERS=':'
387         /VARIABLES=username A20
388                    password A40
389                    uid F10
390                    gid F10
391                    gecos A40
392                    home A40
393                    shell A40.
394 @end example
395
396 @noindent
397 Consider the following data on used cars:
398
399 @example
400 model   year    mileage price   type    age
401 Civic   2002    29883   15900   Si      2
402 Civic   2003    13415   15900   EX      1
403 Civic   1992    107000  3800    n/a     12
404 Accord  2002    26613   17900   EX      1
405 @end example
406
407 @noindent
408 The following syntax can be used to read the used car data:
409
410 @c If you change this example, change the regression test in
411 @c tests/command/get-data-txt-examples.sh to match.
412 @example
413 GET DATA /TYPE=TXT /FILE='cars.data' /DELIMITERS=' ' /FIRSTCASE=2
414         /VARIABLES=model A8
415                    year F4
416                    mileage F6
417                    price F5
418                    type A4
419                    age F2.
420 @end example
421
422 @noindent
423 Consider the following information on animals in a pet store:
424
425 @example
426 "Pet Name", "Age", "Color", "Date Received", "Price", "Needs Walking", "Type"
427 , (Years), , , (Dollars), ,
428 "Rover", 4.5, Brown, "12 Feb 2004", 80, True, "Dog"
429 "Charlie", , Gold, "5 Apr 2007", 12.3, False, "Fish"
430 "Molly", 2, Black, "12 Dec 2006", 25, False, "Cat"
431 "Gilly", , White, "10 Apr 2007", 10, False, "Guinea Pig"
432 @end example
433
434 @noindent
435 The following syntax can be used to read the pet store data:
436
437 @c If you change this example, change the regression test in
438 @c tests/command/get-data-txt-examples.sh to match.
439 @example
440 GET DATA /TYPE=TXT /FILE='pets.data' /DELIMITERS=', ' /QUALIFIER='"'
441         /FIRSTCASE=3
442         /VARIABLES=name A10
443                    age F3.1
444                    color A5
445                    received EDATE10
446                    price F5.2
447                    needs_walking A5
448                    type A10.
449 @end example
450
451 @node GET DATA /TYPE=TXT /ARRANGEMENT=FIXED
452 @subsubsection Reading Fixed Columnar Data
453
454 @display
455 GET DATA /TYPE=TXT
456         /FILE=@{'file-name',file_handle@}
457         [/ARRANGEMENT=@{DELIMITED,FIXED@}]
458         [/FIRSTCASE=@{first_case@}]
459         [/IMPORTCASE=@{ALL,FIRST max_cases,PERCENT percent@}]
460
461         [/FIXCASE=n]
462         /VARIABLES fixed_var [fixed_var]@dots{}
463             [/rec# fixed_var [fixed_var]@dots{}]@dots{}
464 where each fixed_var takes the form:
465         variable start-end format
466 @end display
467
468 The GET DATA command with TYPE=TXT and ARRANGEMENT=FIXED reads input
469 data from text files in fixed format, where each field is located in
470 particular fixed column positions within records of a case.  Its
471 capabilities are similar to those of DATA LIST FIXED (@pxref{DATA LIST
472 FIXED}), with a few enhancements.
473
474 The required FILE subcommand and optional FIRSTCASE and IMPORTCASE
475 subcommands are described above (@pxref{GET DATA /TYPE=TXT}).
476
477 The optional FIXCASE subcommand may be used to specify the positive
478 integer number of input lines that make up each case.  The default
479 value is 1.
480
481 The VARIABLES subcommand, which is required, specifies the positions
482 at which each variable can be found.  For each variable, specify its
483 name, followed by its start and end column separated by @samp{-}
484 (e.g.@: @samp{0-9}), followed by the input format type (e.g.@:
485 @samp{F}).  For this command, columns are numbered starting from 0 at
486 the left column.  Introduce the variables in the second and later
487 lines of a case by a slash followed by the number of the line within
488 the case, e.g.@: @samp{/2} for the second line.
489
490 @subsubheading Examples
491
492 @noindent
493 Consider the following data on used cars:
494
495 @example
496 model   year    mileage price   type    age
497 Civic   2002    29883   15900   Si      2
498 Civic   2003    13415   15900   EX      1
499 Civic   1992    107000  3800    n/a     12
500 Accord  2002    26613   17900   EX      1
501 @end example
502
503 @noindent
504 The following syntax can be used to read the used car data:
505
506 @c If you change this example, change the regression test in
507 @c tests/command/get-data-txt-examples.sh to match.
508 @example
509 GET DATA /TYPE=TXT /FILE='cars.data' /ARRANGEMENT=FIXED /FIRSTCASE=2
510         /VARIABLES=model 0-7 A
511                    year 8-15 F
512                    mileage 16-23 F
513                    price 24-31 F
514                    type 32-40 A
515                    age 40-47 F.
516 @end example
517
518 @node IMPORT
519 @section IMPORT
520 @vindex IMPORT
521
522 @display
523 IMPORT
524         /FILE='file-name'
525         /TYPE=@{COMM,TAPE@}
526         /DROP=var_list
527         /KEEP=var_list
528         /RENAME=(src_names=target_names)@dots{}
529 @end display
530
531 The @cmd{IMPORT} transformation clears the active file dictionary and
532 data and
533 replaces them with a dictionary and data from a system, portable file,
534 or scratch file.
535
536 The FILE subcommand, which is the only required subcommand, specifies
537 the portable file to be read as a file name string or a file handle
538 (@pxref{File Handles}).
539
540 The TYPE subcommand is currently not used.
541
542 DROP, KEEP, and RENAME follow the syntax used by @cmd{GET} (@pxref{GET}).
543
544 @cmd{IMPORT} does not cause the data to be read, only the dictionary.  The
545 data is read later, when a procedure is executed.
546
547 Use of @cmd{IMPORT} to read a system file or scratch file is a PSPP
548 extension.
549
550 @node MATCH FILES
551 @section MATCH FILES
552 @vindex MATCH FILES
553
554 @display
555 MATCH FILES
556         /@{FILE,TABLE@}=@{*,'file-name'@}
557         /RENAME=(src_names=target_names)@dots{}
558         /IN=var_name
559
560         /BY=var_list
561         /DROP=var_list
562         /KEEP=var_list
563         /FIRST=var_name
564         /LAST=var_name
565         /MAP
566 @end display
567
568 @cmd{MATCH FILES} merges one or more system, portable, or scratch files,
569 optionally
570 including the active file.  Cases with the same values for BY
571 variables are combined into a single case.  Cases with different
572 values are output in order.  Thus, multiple sorted files are
573 combined into a single sorted file based on the value of the BY
574 variables.  The results of the merge become the new active file.
575
576 Specify FILE with a system, portable, or scratch file as a file name
577 string or file handle
578 (@pxref{File Handles}), or with an asterisk (@samp{*}) to
579 indicate the current active file.  The files specified on FILE are
580 merged together based on the BY variables, or combined case-by-case if
581 BY is not specified.
582
583 Specify TABLE with a file to use it as a @dfn{table
584 lookup file}.  Cases in table lookup files are not used up after
585 they've been used once.  This means that data in table lookup files can
586 correspond to any number of cases in FILE files.  Table lookup files
587 correspond to lookup tables in traditional relational database systems.
588 If a table lookup file contains more than one case with a given set of
589 BY variables, only the first case is used.
590
591 Any number of FILE and TABLE subcommands may be specified.
592 Ordinarily, at least two FILE subcommands, or one FILE and at least
593 one TABLE, should be specified.  Each instance of FILE or TABLE can be
594 followed by any sequence of RENAME subcommands.  These have the same
595 form and meaning as the corresponding subcommands of @cmd{GET}
596 (@pxref{GET}), but apply only to variables in the given file.
597
598 Each FILE or TABLE may optionally be followed by an IN subcommand,
599 which creates a numeric variable with the specified name and format
600 F1.0.  The IN variable takes value 1 in a case if the given file
601 contributed a row to the merged file, 0 otherwise.  The DROP, KEEP,
602 and RENAME subcommands do not affect IN variables.
603
604 When more than one FILE or TABLE contains a variable with a given
605 name, those variables must all have the same type (numeric or string)
606 and, for string variables, the same width.  This rules applies to
607 variable names after renaming with RENAME; thus, RENAME can be used to
608 resolve conflicts.
609
610 FILE and TABLE must be specified at the beginning of the command, with
611 any RENAME or IN specifications immediately after the corresponding
612 FILE or TABLE.  These subcommands are followed by BY, DROP, KEEP,
613 FIRST, LAST, and MAP.
614
615 The BY subcommand specifies a list of variables that are used to match
616 cases from each of the files.  When TABLE or IN is used, BY is
617 required; otherwise, it is optional.  When BY is specified, all the
618 files named on FILE and TABLE subcommands must be sorted in ascending
619 order of the BY variables.  Variables belonging to files that are not
620 present for the current case are set to the system-missing value for
621 numeric variables or spaces for string variables.
622
623 The DROP and KEEP subcommands allow variables to be dropped from or
624 reordered within the new active file.  These subcommands have the same
625 form and meaning as the corresponding subcommands of @cmd{GET}
626 (@pxref{GET}).  They apply to the new active file as a whole, not to
627 individual input files.  The variable names specified on DROP and KEEP
628 are those after any renaming with RENAME.
629
630 The optional FIRST and LAST subcommands name variables that @cmd{MATCH
631 FILES} adds to the active file.  The new variables are numeric with
632 print and write format F1.0.  The value of the FIRST variable is 1 in
633 the first case with a given set of values for the BY variables, and 0
634 in other cases.  Similarly, the LAST variable is 1 in the last case
635 with a given of BY values, and 0 in other cases.
636
637 @cmd{MATCH FILES} may not be specified following @cmd{TEMPORARY}
638 (@pxref{TEMPORARY}) if the active file is used as an input source.
639
640 Use of portable or scratch files on @cmd{MATCH FILES} is a PSPP
641 extension.
642
643 @node SAVE
644 @section SAVE
645 @vindex SAVE
646
647 @display
648 SAVE
649         /OUTFILE=@{'file-name',file_handle@}
650         /UNSELECTED=@{RETAIN,DELETE@}
651         /@{COMPRESSED,UNCOMPRESSED@}
652         /PERMISSIONS=@{WRITEABLE,READONLY@}
653         /DROP=var_list
654         /KEEP=var_list
655         /VERSION=version
656         /RENAME=(src_names=target_names)@dots{}
657         /NAMES
658         /MAP
659 @end display
660
661 The @cmd{SAVE} procedure causes the dictionary and data in the active
662 file to
663 be written to a system file or scratch file.
664
665 OUTFILE is the only required subcommand.  Specify the system file or
666 scratch file to be written as a string file name or a file handle
667 (@pxref{File Handles}).
668
669 By default, cases excluded with FILTER are written to the system file.
670 These can be excluded by specifying DELETE on the UNSELECTED
671 subcommand.  Specifying RETAIN makes the default explicit.
672
673 The COMPRESS and UNCOMPRESS subcommand determine whether the saved
674 system file is compressed.  By default, system files are compressed.
675 This default can be changed with the SET command (@pxref{SET}).
676
677 The PERMISSIONS subcommand specifies permissions for the new system
678 file.  WRITEABLE, the default, creates the file with read and write
679 permission.  READONLY creates the file for read-only access.
680
681 By default, all the variables in the active file dictionary are written
682 to the system file.  The DROP subcommand can be used to specify a list
683 of variables not to be written.  In contrast, KEEP specifies variables
684 to be written, with all variables not specified not written.
685
686 Normally variables are saved to a system file under the same names they
687 have in the active file.  Use the RENAME subcommand to change these names.
688 Specify, within parentheses, a list of variable names followed by an
689 equals sign (@samp{=}) and the names that they should be renamed to.
690 Multiple parenthesized groups of variable names can be included on a
691 single RENAME subcommand.  Variables' names may be swapped using a
692 RENAME subcommand of the form @samp{/RENAME=(A B=B A)}.
693
694 Alternate syntax for the RENAME subcommand allows the parentheses to be
695 eliminated.  When this is done, only a single variable may be renamed at
696 once.  For instance, @samp{/RENAME=A=B}.  This alternate syntax is
697 deprecated.
698
699 DROP, KEEP, and RENAME are performed in left-to-right order.  They
700 each may be present any number of times.  @cmd{SAVE} never modifies
701 the active file.  DROP, KEEP, and RENAME only affect the system file
702 written to disk.
703
704 The VERSION subcommand specifies the version of the file format. Valid
705 versions are 2 and 3.  The default version is 3.  In version 2 system
706 files, variable names longer than 8 bytes will be truncated.  The two
707 versions are otherwise identical.
708
709 The NAMES and MAP subcommands are currently ignored.
710
711 @cmd{SAVE} causes the data to be read.  It is a procedure.
712
713 @node SYSFILE INFO
714 @section SYSFILE INFO
715 @vindex SYSFILE INFO
716
717 @display 
718 SYSFILE INFO FILE='file-name'.
719 @end display
720
721 @cmd{SYSFILE INFO} reads the dictionary in a system file and
722 displays the information in its dictionary.
723
724 Specify a file name or file handle.  @cmd{SYSFILE INFO} reads that file as
725 a system file and displays information on its dictionary.
726
727 @cmd{SYSFILE INFO} does not affect the current active file.
728
729 @node XEXPORT
730 @section XEXPORT
731 @vindex XEXPORT
732
733 @display
734 XEXPORT
735         /OUTFILE='file-name'
736         /DIGITS=n
737         /DROP=var_list
738         /KEEP=var_list
739         /RENAME=(src_names=target_names)@dots{}
740         /TYPE=@{COMM,TAPE@}
741         /MAP
742 @end display
743
744 The @cmd{EXPORT} transformation writes the active file dictionary and
745 data to a specified portable file.
746
747 This transformation is a PSPP extension.
748
749 It is similar to the @cmd{EXPORT} procedure, with two differences:
750
751 @itemize
752 @item
753 @cmd{XEXPORT} is a transformation, not a procedure.  It is executed when
754 the data is read by a procedure or procedure-like command.
755
756 @item
757 @cmd{XEXPORT} does not support the UNSELECTED subcommand.
758 @end itemize
759
760 @xref{EXPORT}, for more information.
761
762 @node XSAVE
763 @section XSAVE
764 @vindex XSAVE
765
766 @display
767 XSAVE
768         /OUTFILE='file-name'
769         /@{COMPRESSED,UNCOMPRESSED@}
770         /PERMISSIONS=@{WRITEABLE,READONLY@}
771         /DROP=var_list
772         /KEEP=var_list
773         /VERSION=version
774         /RENAME=(src_names=target_names)@dots{}
775         /NAMES
776         /MAP
777 @end display
778
779 The @cmd{XSAVE} transformation writes the active file dictionary and
780 data to a system file or scratch file.  It is similar to the @cmd{SAVE}
781 procedure, with two differences:
782
783 @itemize
784 @item
785 @cmd{XSAVE} is a transformation, not a procedure.  It is executed when
786 the data is read by a procedure or procedure-like command.
787
788 @item
789 @cmd{XSAVE} does not support the UNSELECTED subcommand.
790 @end itemize
791
792 @xref{SAVE}, for more information.
793 @setfilename ignored