FILE HANDLE: Add new ENDS subcommand to control new-lines in output.
[pspp] / doc / data-io.texi
1 @c (modify-syntax-entry ?_ "w")
2 @c (modify-syntax-entry ?' "'")
3 @c (modify-syntax-entry ?@ "'")
4
5
6 @node Data Input and Output
7 @chapter Data Input and Output
8 @cindex input
9 @cindex output
10 @cindex data
11 @cindex cases
12 @cindex observations
13
14 Data are the focus of the @pspp{} language.  
15 Each datum  belongs to a @dfn{case} (also called an @dfn{observation}).
16 Each case represents an individual or ``experimental unit''.
17 For example, in the results of a survey, the names of the respondents,
18 their sex, age, etc.@: and their responses are all data and the data
19 pertaining to single respondent is a case.
20 This chapter examines
21 the @pspp{} commands for defining variables and reading and writing data.
22 There are alternative commands to  read data from predefined sources
23 such as system files or databases (@xref{GET, GET DATA}.)
24
25 @quotation Note
26 These commands tell @pspp{} how to read data, but the data will not
27 actually be read until a procedure is executed.
28 @end quotation
29
30 @menu
31 * BEGIN DATA::                  Embed data within a syntax file.
32 * CLOSE FILE HANDLE::           Close a file handle.
33 * DATAFILE ATTRIBUTE::          Set custom attributes on data files.
34 * DATASET::                     Manage multiple datasets.
35 * DATA LIST::                   Fundamental data reading command.
36 * END CASE::                    Output the current case.
37 * END FILE::                    Terminate the current input program.
38 * FILE HANDLE::                 Support for special file formats.
39 * INPUT PROGRAM::               Support for complex input programs.
40 * LIST::                        List cases in the active dataset.
41 * NEW FILE::                    Clear the active dataset.
42 * PRINT::                       Display values in print formats.
43 * PRINT EJECT::                 Eject the current page then print.
44 * PRINT SPACE::                 Print blank lines.
45 * REREAD::                      Take another look at the previous input line.
46 * REPEATING DATA::              Multiple cases on a single line.
47 * WRITE::                       Display values in write formats.
48 @end menu
49
50 @node BEGIN DATA
51 @section BEGIN DATA
52 @vindex BEGIN DATA
53 @vindex END DATA
54 @cindex Embedding data in syntax files
55 @cindex Data, embedding in syntax files
56
57 @display
58 BEGIN DATA.
59 @dots{}
60 END DATA.
61 @end display
62
63 @cmd{BEGIN DATA} and @cmd{END DATA} can be used to embed raw ASCII
64 data in a @pspp{} syntax file.  @cmd{DATA LIST} or another input
65 procedure must be used before @cmd{BEGIN DATA} (@pxref{DATA LIST}).
66 @cmd{BEGIN DATA} and @cmd{END DATA} must be used together.  @cmd{END
67 DATA} must appear by itself on a single line, with no leading
68 white space and exactly one space between the words @code{END} and
69 @code{DATA}, like this:
70
71 @example
72 END DATA.
73 @end example
74
75 @node CLOSE FILE HANDLE
76 @section CLOSE FILE HANDLE
77
78 @display
79 CLOSE FILE HANDLE @var{handle_name}.
80 @end display
81
82 @cmd{CLOSE FILE HANDLE} disassociates the name of a file handle with a
83 given file.  The only specification is the name of the handle to close.
84 Afterward
85 @cmd{FILE HANDLE}.
86
87 The file named INLINE, which represents data entered between @cmd{BEGIN
88 DATA} and @cmd{END DATA}, cannot be closed.  Attempts to close it with
89 @cmd{CLOSE FILE HANDLE} have no effect.
90
91 @cmd{CLOSE FILE HANDLE} is a @pspp{} extension.
92
93 @node DATAFILE ATTRIBUTE
94 @section DATAFILE ATTRIBUTE
95 @vindex DATAFILE ATTRIBUTE
96
97 @display
98 DATAFILE ATTRIBUTE
99          ATTRIBUTE=@var{name}('@var{value}') [@var{name}('@var{value}')]@dots{}
100          ATTRIBUTE=@var{name}@b{[}@var{index}@b{]}('@var{value}') [@var{name}@b{[}@var{index}@b{]}('@var{value}')]@dots{}
101          DELETE=@var{name} [@var{name}]@dots{}
102          DELETE=@var{name}@b{[}@var{index}@b{]} [@var{name}@b{[}@var{index}@b{]}]@dots{}
103 @end display
104
105 @cmd{DATAFILE ATTRIBUTE} adds, modifies, or removes user-defined
106 attributes associated with the active dataset.  Custom data file
107 attributes are not interpreted by @pspp{}, but they are saved as part of
108 system files and may be used by other software that reads them.
109
110 Use the @subcmd{ATTRIBUTE} subcommand to add or modify a custom data file
111 attribute.  Specify the name of the attribute as an identifier
112 (@pxref{Tokens}), followed by the desired value, in parentheses, as a
113 quoted string.  Attribute names that begin with @code{$} are reserved
114 for @pspp{}'s internal use, and attribute names that begin with @code{@@}
115 or @code{$@@} are not displayed by most @pspp{} commands that display
116 other attributes.  Other attribute names are not treated specially.
117
118 Attributes may also be organized into arrays.  To assign to an array
119 element, add an integer array index enclosed in square brackets
120 (@code{[} and @code{]}) between the attribute name and value.  Array
121 indexes start at 1, not 0.  An attribute array that has a single
122 element (number 1) is not distinguished from a non-array attribute.
123
124 Use the @subcmd{DELETE} subcommand to delete an attribute.  Specify an
125 attribute name by itself to delete an entire attribute, including all
126 array elements for attribute arrays.  Specify an attribute name
127 followed by an array index in square brackets to delete a single
128 element of an attribute array.  In the latter case, all the array
129 elements numbered higher than the deleted element are shifted down,
130 filling the vacated position.
131
132 To associate custom attributes with particular variables, instead of
133 with the entire active dataset, use @cmd{VARIABLE ATTRIBUTE}
134 (@pxref{VARIABLE ATTRIBUTE}) instead.
135
136 @cmd{DATAFILE ATTRIBUTE} takes effect immediately.  It is not affected
137 by conditional and looping structures such as @cmd{DO IF} or
138 @cmd{LOOP}.
139
140 @node DATASET
141 @section DATASET commands
142 @vindex DATASET
143
144 @display
145 DATASET NAME @var{name} [WINDOW=@{ASIS,FRONT@}].
146 DATASET ACTIVATE @var{name} [WINDOW=@{ASIS,FRONT@}].
147 DATASET COPY @var{name} [WINDOW=@{MINIMIZED,HIDDEN,FRONT@}].
148 DATASET DECLARE @var{name} [WINDOW=@{MINIMIZED,HIDDEN,FRONT@}].
149 DATASET CLOSE @{@var{name},*,ALL@}.
150 DATASET DISPLAY.
151 @end display
152
153 The @cmd{DATASET} commands simplify use of multiple datasets within a
154 @pspp{} session.  They allow datasets to be created and destroyed.  At
155 any given time, most @pspp{} commands work with a single dataset, called
156 the active dataset.
157
158 @vindex DATASET NAME
159 The DATASET NAME command gives the active dataset the specified name, or
160 if it already had a name, it renames it.  If another dataset already
161 had the given name, that dataset is deleted.
162
163 @vindex DATASET ACTIVATE
164 The DATASET ACTIVATE command selects the named dataset, which must
165 already exist, as the active dataset.  Before switching the active
166 dataset, any pending transformations are executed, as if @cmd{EXECUTE}
167 had been specified.  If the active dataset is unnamed before
168 switching, then it is deleted and becomes unavailable after switching.
169
170 @vindex DATASET COPY
171 The DATASET COPY command creates a new dataset with the specified
172 name, whose contents are a copy of the active dataset.  Any pending
173 transformations are executed, as if @cmd{EXECUTE} had been specified,
174 before making the copy.  If a dataset with the given name already
175 exists, it is replaced.  If the name is the name of the active
176 dataset, then the active dataset becomes unnamed.
177
178 @vindex DATASET DECLARE
179 The DATASET DECLARE command creates a new dataset that is initially
180 ``empty,'' that is, it has no dictionary or data.  If a dataset with
181 the given name already exists, this has no effect.  The new dataset
182 can be used with commands that support output to a dataset,
183 e.g. AGGREGATE (@pxref{AGGREGATE}).
184
185 @vindex DATASET CLOSE
186 The DATASET CLOSE command deletes a dataset.  If the active dataset is
187 specified by name, or if @samp{*} is specified, then the active
188 dataset becomes unnamed.  If a different dataset is specified by name,
189 then it is deleted and becomes unavailable.  Specifying ALL deletes
190 all datasets except for the active dataset, which becomes unnamed.
191
192 @vindex DATASET DISPLAY
193 The DATASET DISPLAY command lists all the currently defined datasets.
194
195 Many DATASET commands accept an optional @subcmd{WINDOW} subcommand.  In the
196 @pspp{}IRE GUI, the value given for this subcommand influences how the
197 dataset's window is displayed.  Outside the GUI, the @subcmd{WINDOW} subcommand
198 has no effect.  The valid values are:
199
200 @table @asis
201 @item ASIS
202 Do not change how the window is displayed.  This is the default for
203 DATASET NAME and DATASET ACTIVATE.
204
205 @item FRONT
206 Raise the dataset's window to the top.  Make it the default dataset
207 for running syntax.
208
209 @item MINIMIZED
210 Display the window ``minimized'' to an icon.  Prefer other datasets
211 for running syntax.  This is the default for DATASET COPY and DATASET
212 DECLARE.
213
214 @item HIDDEN
215 Hide the dataset's window.  Prefer other datasets for running syntax.
216 @end table
217
218 @node DATA LIST
219 @section DATA LIST
220 @vindex DATA LIST
221 @cindex reading data from a file
222 @cindex data, reading from a file
223 @cindex data, embedding in syntax files
224 @cindex embedding data in syntax files
225
226 Used to read text or binary data, @cmd{DATA LIST} is the most
227 fundamental data-reading command.  Even the more sophisticated input
228 methods use @cmd{DATA LIST} commands as a building block.
229 Understanding @cmd{DATA LIST} is important to understanding how to use
230 @pspp{} to read your data files.
231
232 There are two major variants of @cmd{DATA LIST}, which are fixed
233 format and free format.  In addition, free format has a minor variant,
234 list format, which is discussed in terms of its differences from vanilla
235 free format.
236
237 Each form of @cmd{DATA LIST} is described in detail below.
238
239 @xref{GET DATA}, for a command that offers a few enhancements over
240 DATA LIST and that may be substituted for DATA LIST in many
241 situations.
242
243 @menu
244 * DATA LIST FIXED::             Fixed columnar locations for data.
245 * DATA LIST FREE::              Any spacing you like.
246 * DATA LIST LIST::              Each case must be on a single line.
247 @end menu
248
249 @node DATA LIST FIXED
250 @subsection DATA LIST FIXED
251 @vindex DATA LIST FIXED
252 @cindex reading fixed-format data
253 @cindex fixed-format data, reading
254 @cindex data, fixed-format, reading
255 @cindex embedding fixed-format data
256
257 @display
258 DATA LIST [FIXED]
259         @{TABLE,NOTABLE@}
260         [FILE='@var{file_name}' [ENCODING='@var{encoding}']]
261         [RECORDS=@var{record_count}]
262         [END=@var{end_var}]
263         [SKIP=@var{record_count}]
264         /[line_no] @var{var_spec}@dots{}
265
266 where each @var{var_spec} takes one of the forms
267         @var{var_list} @var{start}-@var{end} [@var{type_spec}]
268         @var{var_list} (@var{fortran_spec})
269 @end display
270
271 @cmd{DATA LIST FIXED} is used to read data files that have values at fixed
272 positions on each line of single-line or multiline records.  The
273 keyword FIXED is optional.
274
275 The @subcmd{FILE} subcommand must be used if input is to be taken from an
276 external file.  It may be used to specify a file name as a string or a
277 file handle (@pxref{File Handles}).  If the @subcmd{FILE} subcommand is not used,
278 then input is assumed to be specified within the command file using
279 @cmd{BEGIN DATA}@dots{}@cmd{END DATA} (@pxref{BEGIN DATA}).
280 The @subcmd{ENCODING} subcommand may only be used if the @subcmd{FILE}
281 subcommand is also used.  It specifies the character encoding of the
282 file.  @xref{INSERT}, for information on supported encodings.
283
284 The optional @subcmd{RECORDS} subcommand, which takes a single integer as an
285 argument, is used to specify the number of lines per record.
286 If @subcmd{RECORDS}
287 is not specified, then the number of lines per record is calculated from
288 the list of variable specifications later in @cmd{DATA LIST}.
289
290 The @subcmd{END} subcommand is only useful in conjunction with @cmd{INPUT
291 PROGRAM}.  @xref{INPUT PROGRAM}, for details.
292
293 The optional @subcmd{SKIP} subcommand specifies a number of records to skip at
294 the beginning of an input file.  It can be used to skip over a row
295 that contains variable names, for example.
296
297 @cmd{DATA LIST} can optionally output a table describing how the data file
298 will be read.  The @subcmd{TABLE} subcommand enables this output, and
299 @subcmd{NOTABLE} disables it.  The default is to output the table.
300
301 The list of variables to be read from the data list must come last.
302 Each line in the data record is introduced by a slash (@samp{/}).
303 Optionally, a line number may follow the slash.  Following, any number
304 of variable specifications may be present.
305
306 Each variable specification consists of a list of variable names
307 followed by a description of their location on the input line.  Sets of
308 variables may be specified using the @cmd{DATA LIST} @subcmd{TO} convention
309 (@pxref{Sets of
310 Variables}).  There are two ways to specify the location of the variable
311 on the line: columnar style and FORTRAN style.
312
313 In columnar style, the starting column and ending column for the field
314 are specified after the variable name, separated by a dash (@samp{-}).
315 For instance, the third through fifth columns on a line would be
316 specified @samp{3-5}.  By default, variables are considered to be in
317 @samp{F} format (@pxref{Input and Output Formats}).  (This default can be
318 changed; see @ref{SET} for more information.)
319
320 In columnar style, to use a variable format other than the default,
321 specify the format type in parentheses after the column numbers.  For
322 instance, for alphanumeric @samp{A} format, use @samp{(A)}.  
323
324 In addition, implied decimal places can be specified in parentheses
325 after the column numbers.  As an example, suppose that a data file has a
326 field in which the characters @samp{1234} should be interpreted as
327 having the value 12.34.  Then this field has two implied decimal places,
328 and the corresponding specification would be @samp{(2)}.  If a field
329 that has implied decimal places contains a decimal point, then the
330 implied decimal places are not applied.
331
332 Changing the variable format and adding implied decimal places can be
333 done together; for instance, @samp{(N,5)}.
334
335 When using columnar style, the input and output width of each variable is
336 computed from the field width.  The field width must be evenly divisible
337 into the number of variables specified.
338
339 FORTRAN style is an altogether different approach to specifying field
340 locations.  With this approach, a list of variable input format
341 specifications, separated by commas, are placed after the variable names
342 inside parentheses.  Each format specifier advances as many characters
343 into the input line as it uses.
344
345 Implied decimal places also exist in FORTRAN style.  A format
346 specification with @var{d} decimal places also has @var{d} implied
347 decimal places.
348
349 In addition to the standard format specifiers (@pxref{Input and Output
350 Formats}), FORTRAN style defines some extensions:
351
352 @table @asis
353 @item @code{X}
354 Advance the current column on this line by one character position.
355
356 @item @code{T}@var{x}
357 Set the current column on this line to column @var{x}, with column
358 numbers considered to begin with 1 at the left margin.
359
360 @item @code{NEWREC}@var{x}
361 Skip forward @var{x} lines in the current record, resetting the active
362 column to the left margin.
363
364 @item Repeat count
365 Any format specifier may be preceded by a number.  This causes the
366 action of that format specifier to be repeated the specified number of
367 times.
368
369 @item (@var{spec1}, @dots{}, @var{specN})
370 Group the given specifiers together.  This is most useful when preceded
371 by a repeat count.  Groups may be nested arbitrarily.
372 @end table
373
374 FORTRAN and columnar styles may be freely intermixed.  Columnar style
375 leaves the active column immediately after the ending column
376 specified.  Record motion using @code{NEWREC} in FORTRAN style also
377 applies to later FORTRAN and columnar specifiers.
378  
379 @menu
380 * DATA LIST FIXED Examples::    Examples of DATA LIST FIXED.
381 @end menu
382
383 @node DATA LIST FIXED Examples
384 @unnumberedsubsubsec Examples
385
386 @enumerate
387 @item
388 @example
389 DATA LIST TABLE /NAME 1-10 (A) INFO1 TO INFO3 12-17 (1).
390
391 BEGIN DATA.
392 John Smith 102311
393 Bob Arnold 122015
394 Bill Yates  918 6
395 END DATA.
396 @end example
397
398 Defines the following variables:
399
400 @itemize @bullet
401 @item
402 @code{NAME}, a 10-character-wide string variable, in columns 1
403 through 10.
404
405 @item
406 @code{INFO1}, a numeric variable, in columns 12 through 13.
407
408 @item
409 @code{INFO2}, a numeric variable, in columns 14 through 15.
410
411 @item
412 @code{INFO3}, a numeric variable, in columns 16 through 17.
413 @end itemize
414
415 The @code{BEGIN DATA}/@code{END DATA} commands cause three cases to be
416 defined:
417
418 @example
419 Case   NAME         INFO1   INFO2   INFO3
420    1   John Smith     10      23      11
421    2   Bob Arnold     12      20      15
422    3   Bill Yates      9      18       6
423 @end example
424
425 The @code{TABLE} keyword causes @pspp{} to print out a table
426 describing the four variables defined.
427
428 @item
429 @example
430 DAT LIS FIL="survey.dat"
431         /ID 1-5 NAME 7-36 (A) SURNAME 38-67 (A) MINITIAL 69 (A)
432         /Q01 TO Q50 7-56
433         /.
434 @end example
435
436 Defines the following variables:
437
438 @itemize @bullet
439 @item
440 @code{ID}, a numeric variable, in columns 1-5 of the first record.
441
442 @item
443 @code{NAME}, a 30-character string variable, in columns 7-36 of the
444 first record.
445
446 @item
447 @code{SURNAME}, a 30-character string variable, in columns 38-67 of
448 the first record.
449
450 @item
451 @code{MINITIAL}, a 1-character string variable, in column 69 of
452 the first record.
453
454 @item
455 Fifty variables @code{Q01}, @code{Q02}, @code{Q03}, @dots{}, @code{Q49},
456 @code{Q50}, all numeric, @code{Q01} in column 7, @code{Q02} in column 8,
457 @dots{}, @code{Q49} in column 55, @code{Q50} in column 56, all in the second
458 record.
459 @end itemize
460
461 Cases are separated by a blank record.
462
463 Data is read from file @file{survey.dat} in the current directory.
464
465 This example shows keywords abbreviated to their first 3 letters.
466
467 @end enumerate
468
469 @node DATA LIST FREE
470 @subsection DATA LIST FREE
471 @vindex DATA LIST FREE
472
473 @display
474 DATA LIST FREE
475         [(@{TAB,'@var{c}'@}, @dots{})]
476         [@{NOTABLE,TABLE@}]
477         [FILE='@var{file_name}' [ENCODING='@var{encoding}']]
478         [SKIP=@var{record_cnt}]
479         /@var{var_spec}@dots{}
480
481 where each @var{var_spec} takes one of the forms
482         @var{var_list} [(@var{type_spec})]
483         @var{var_list} *
484 @end display
485
486 In free format, the input data is, by default, structured as a series
487 of fields separated by spaces, tabs, commas, or line breaks.  Each
488 field's content may be unquoted, or it may be quoted with a pairs of
489 apostrophes (@samp{'}) or double quotes (@samp{"}).  Unquoted white
490 space separates fields but is not part of any field.  Any mix of
491 spaces, tabs, and line breaks is equivalent to a single space for the
492 purpose of separating fields, but consecutive commas will skip a
493 field.
494
495 Alternatively, delimiters can be specified explicitly, as a
496 parenthesized, comma-separated list of single-character strings
497 immediately following FREE.  The word TAB may also be used to specify
498 a tab character as a delimiter.  When delimiters are specified
499 explicitly, only the given characters, plus line breaks, separate
500 fields.  Furthermore, leading spaces at the beginnings of fields are
501 not trimmed, consecutive delimiters define empty fields, and no form
502 of quoting is allowed.
503
504 The @subcmd{NOTABLE} and @subcmd{TABLE} subcommands are as in @cmd{DATA LIST FIXED} above.
505 @subcmd{NOTABLE} is the default.
506
507 The @subcmd{FILE}, @subcmd{SKIP}, and @subcmd{ENCODING} subcommands
508 are as in @cmd{DATA LIST FIXED} above.
509
510 The variables to be parsed are given as a single list of variable names.
511 This list must be introduced by a single slash (@samp{/}).  The set of
512 variable names may contain format specifications in parentheses
513 (@pxref{Input and Output Formats}).  Format specifications apply to all
514 variables back to the previous parenthesized format specification.  
515
516 In addition, an asterisk may be used to indicate that all variables
517 preceding it are to have input/output format @samp{F8.0}.
518
519 Specified field widths are ignored on input, although all normal limits
520 on field width apply, but they are honored on output.
521
522 @node DATA LIST LIST
523 @subsection DATA LIST LIST
524 @vindex DATA LIST LIST
525
526 @display
527 DATA LIST LIST
528         [(@{TAB,'@var{c}'@}, @dots{})]
529         [@{NOTABLE,TABLE@}]
530         [FILE='@var{file_name}' [ENCODING='@var{encoding}']]
531         [SKIP=@var{record_count}]
532         /@var{var_spec}@dots{}
533
534 where each @var{var_spec} takes one of the forms
535         @var{var_list} [(@var{type_spec})]
536         @var{var_list} *
537 @end display
538
539 With one exception, @cmd{DATA LIST LIST} is syntactically and
540 semantically equivalent to @cmd{DATA LIST FREE}.  The exception is
541 that each input line is expected to correspond to exactly one input
542 record.  If more or fewer fields are found on an input line than
543 expected, an appropriate diagnostic is issued.
544
545 @node END CASE
546 @section END CASE
547 @vindex END CASE
548
549 @display
550 END CASE.
551 @end display
552
553 @cmd{END CASE} is used only within @cmd{INPUT PROGRAM} to output the
554 current case.  @xref{INPUT PROGRAM}, for details.
555
556 @node END FILE
557 @section END FILE
558 @vindex END FILE
559
560 @display
561 END FILE.
562 @end display
563
564 @cmd{END FILE} is used only within @cmd{INPUT PROGRAM} to terminate
565 the current input program.  @xref{INPUT PROGRAM}.
566
567 @node FILE HANDLE
568 @section FILE HANDLE
569 @vindex FILE HANDLE
570
571 @display
572 For text files:
573         FILE HANDLE @var{handle_name}
574                 /NAME='@var{file_name}
575                 [/MODE=CHARACTER]
576                 [/ENDS=@{CR,CRLF@}]
577                 /TABWIDTH=@var{tab_width}
578                 [ENCODING='@var{encoding}']
579
580 For binary files in native encoding with fixed-length records:
581         FILE HANDLE @var{handle_name}
582                 /NAME='@var{file_name}'
583                 /MODE=IMAGE
584                 [/LRECL=@var{rec_len}]
585                 [ENCODING='@var{encoding}']
586
587 For binary files in native encoding with variable-length records:
588         FILE HANDLE @var{handle_name}
589                 /NAME='@var{file_name}'
590                 /MODE=BINARY
591                 [/LRECL=@var{rec_len}]
592                 [ENCODING='@var{encoding}']
593
594 For binary files encoded in EBCDIC:
595         FILE HANDLE @var{handle_name}
596                 /NAME='@var{file_name}'
597                 /MODE=360
598                 /RECFORM=@{FIXED,VARIABLE,SPANNED@}
599                 [/LRECL=@var{rec_len}]
600                 [ENCODING='@var{encoding}']
601 @end display
602
603 Use @cmd{FILE HANDLE} to associate a file handle name with a file and
604 its attributes, so that later commands can refer to the file by its
605 handle name.  Names of text files can be specified directly on
606 commands that access files, so that @cmd{FILE HANDLE} is only needed when a
607 file is not an ordinary file containing lines of text.  However,
608 @cmd{FILE HANDLE} may be used even for text files, and it may be
609 easier to specify a file's name once and later refer to it by an
610 abstract handle.
611
612 Specify the file handle name as the identifier immediately following the
613 @cmd{FILE HANDLE} command name.  The identifier INLINE is reserved for
614 representing data embedded in the syntax file (@pxref{BEGIN DATA}) The
615 file handle name must not already have been used in a previous
616 invocation of @cmd{FILE HANDLE}, unless it has been closed by an
617 intervening command (@pxref{CLOSE FILE HANDLE}).
618
619 The effect and syntax of @cmd{FILE HANDLE} depends on the selected MODE:
620
621 @itemize
622 @item
623 In CHARACTER mode, the default, the data file is read as a text file.
624 Each text line is read as one record.
625
626 In CHARACTER mode only, tabs are expanded to spaces by input programs,
627 except by @cmd{DATA LIST FREE} with explicitly specified delimiters.
628 Each tab is 4 characters wide by default, but TABWIDTH (a @pspp{}
629 extension) may be used to specify an alternate width.  Use a TABWIDTH
630 of 0 to suppress tab expansion.
631
632 By default, a file written in CHARACTER mode uses line feeds only at
633 ends of lines, which is customary on Unix-like system.  Specify ENDS
634 as CR or CRLF to override the default.  PSPP reads files using either
635 convention on any kind of system, regardless of ENDS.
636
637 @item
638 In IMAGE mode, the data file is treated as a series of fixed-length
639 binary records.  LRECL should be used to specify the record length in
640 bytes, with a default of 1024.  On input, it is an error if an IMAGE
641 file's length is not a integer multiple of the record length.  On
642 output, each record is padded with spaces or truncated, if necessary,
643 to make it exactly the correct length.
644
645 @item
646 In BINARY mode, the data file is treated as a series of
647 variable-length binary records.  LRECL may be specified, but its value
648 is ignored.  The data for each record is both preceded and followed by
649 a 32-bit signed integer in little-endian byte order that specifies the
650 length of the record.  (This redundancy permits records in these
651 files to be efficiently read in reverse order, although @pspp{} always
652 reads them in forward order.)  The length does not include either
653 integer.
654
655 @item
656 Mode 360 reads and writes files in formats first used for tapes in the
657 1960s on IBM mainframe operating systems and still supported today by
658 the modern successors of those operating systems.  For more
659 information, see @cite{OS/400 Tape and Diskette Device Programming},
660 available on IBM's website.
661
662 Alphanumeric data in mode 360 files are encoded in EBCDIC.  @pspp{}
663 translates EBCDIC to or from the host's native format as necessary on
664 input or output, using an ASCII/EBCDIC translation that is one-to-one,
665 so that a ``round trip'' from ASCII to EBCDIC back to ASCII, or vice
666 versa, always yields exactly the original data.
667
668 The @subcmd{RECFORM} subcommand is required in mode 360.  The precise file
669 format depends on its setting:
670
671 @table @asis
672 @item F
673 @itemx FIXED
674 This record format is equivalent to IMAGE mode, except for EBCDIC
675 translation.
676
677 IBM documentation calls this @code{*F} (fixed-length, deblocked)
678 format.
679
680 @item V
681 @itemx VARIABLE
682 The file comprises a sequence of zero or more variable-length blocks.
683 Each block begins with a 4-byte @dfn{block descriptor word} (BDW).
684 The first two bytes of the BDW are an unsigned integer in big-endian
685 byte order that specifies the length of the block, including the BDW
686 itself.  The other two bytes of the BDW are ignored on input and
687 written as zeros on output.
688
689 Following the BDW, the remainder of each block is a sequence of one or
690 more variable-length records, each of which in turn begins with a
691 4-byte @dfn{record descriptor word} (RDW) that has the same format as
692 the BDW.  Following the RDW, the remainder of each record is the
693 record data.
694
695 The maximum length of a record in VARIABLE mode is 65,527 bytes:
696 65,535 bytes (the maximum value of a 16-bit unsigned integer), minus 4
697 bytes for the BDW, minus 4 bytes for the RDW.
698
699 In mode VARIABLE, LRECL specifies a maximum, not a fixed, record
700 length, in bytes.  The default is 8,192.
701
702 IBM documentation calls this @code{*VB} (variable-length, blocked,
703 unspanned) format.
704
705 @item VS
706 @itemx SPANNED
707 The file format is like that of VARIABLE mode, except that logical
708 records may be split among multiple physical records (called
709 @dfn{segments}) or blocks.  In SPANNED mode, the third byte of each
710 RDW is called the segment control character (SCC).  Odd SCC values
711 cause the segment to be appended to a record buffer maintained in
712 memory; even values also append the segment and then flush its
713 contents to the input procedure.  Canonically, SCC value 0 designates
714 a record not spanned among multiple segments, and values 1 through 3
715 designate the first segment, the last segment, or an intermediate
716 segment, respectively, within a multi-segment record.  The record
717 buffer is also flushed at end of file regardless of the final record's
718 SCC.
719
720 The maximum length of a logical record in VARIABLE mode is limited
721 only by memory available to @pspp{}.  Segments are limited to 65,527
722 bytes, as in VARIABLE mode.
723
724 This format is similar to what IBM documentation call @code{*VS}
725 (variable-length, deblocked, spanned) format.
726 @end table
727
728 In mode 360, fields of type A that extend beyond the end of a record
729 read from disk are padded with spaces in the host's native character
730 set, which are then translated from EBCDIC to the native character
731 set.  Thus, when the host's native character set is based on ASCII,
732 these fields are effectively padded with character @code{X'80'}.  This
733 wart is implemented for compatibility.
734 @end itemize
735
736 The @subcmd{NAME} subcommand specifies the name of the file associated with the
737 handle.  It is required in all modes but SCRATCH mode, in which its
738 use is forbidden.
739
740 The ENCODING subcommand specifies the encoding of text in the file.
741 For reading text files in CHARACTER mode, all of the forms described
742 for ENCODING on the INSERT command are supported (@pxref{INSERT}).
743 For reading in other file-based modes, encoding autodetection is not
744 supported; if the specified encoding requests autodetection then the
745 default encoding will be used.  This is also true when a file handle
746 is used for writing a file in any mode.
747
748 @node INPUT PROGRAM
749 @section INPUT PROGRAM
750 @vindex INPUT PROGRAM
751
752 @display
753 INPUT PROGRAM.
754 @dots{} input commands @dots{}
755 END INPUT PROGRAM.
756 @end display
757
758 @cmd{INPUT PROGRAM}@dots{}@cmd{END INPUT PROGRAM} specifies a
759 complex input program.  By placing data input commands within @cmd{INPUT
760 PROGRAM}, @pspp{} programs can take advantage of more complex file
761 structures than available with only @cmd{DATA LIST}.
762
763 The first sort of extended input program is to simply put multiple @cmd{DATA
764 LIST} commands within the @cmd{INPUT PROGRAM}.  This will cause all of
765 the data
766 files to be read in parallel.  Input will stop when end of file is
767 reached on any of the data files.
768
769 Transformations, such as conditional and looping constructs, can also be
770 included within @cmd{INPUT PROGRAM}.  These can be used to combine input
771 from several data files in more complex ways.  However, input will still
772 stop when end of file is reached on any of the data files.
773
774 To prevent @cmd{INPUT PROGRAM} from terminating at the first end of
775 file, use
776 the @subcmd{END} subcommand on @cmd{DATA LIST}.  This subcommand takes a
777 variable name,
778 which should be a numeric scratch variable (@pxref{Scratch Variables}).
779 (It need not be a scratch variable but otherwise the results can be
780 surprising.)  The value of this variable is set to 0 when reading the
781 data file, or 1 when end of file is encountered.
782
783 Two additional commands are useful in conjunction with @cmd{INPUT PROGRAM}.
784 @cmd{END CASE} is the first.  Normally each loop through the
785 @cmd{INPUT PROGRAM}
786 structure produces one case.  @cmd{END CASE} controls exactly
787 when cases are output.  When @cmd{END CASE} is used, looping from the end of
788 @cmd{INPUT PROGRAM} to the beginning does not cause a case to be output.
789
790 @cmd{END FILE} is the second.  When the @subcmd{END} subcommand is used on @cmd{DATA
791 LIST}, there is no way for the @cmd{INPUT PROGRAM} construct to stop
792 looping,
793 so an infinite loop results.  @cmd{END FILE}, when executed,
794 stops the flow of input data and passes out of the @cmd{INPUT PROGRAM}
795 structure.
796
797 All this is very confusing.  A few examples should help to clarify.
798
799 @c If you change this example, change the regression test1 in
800 @c tests/command/input-program.sh to match.
801 @example
802 INPUT PROGRAM.
803         DATA LIST NOTABLE FILE='a.data'/X 1-10.
804         DATA LIST NOTABLE FILE='b.data'/Y 1-10.
805 END INPUT PROGRAM.
806 LIST.
807 @end example
808
809 The example above reads variable X from file @file{a.data} and variable
810 Y from file @file{b.data}.  If one file is shorter than the other then
811 the extra data in the longer file is ignored.
812
813 @c If you change this example, change the regression test2 in
814 @c tests/command/input-program.sh to match.
815 @example
816 INPUT PROGRAM.
817         NUMERIC #A #B.
818         
819         DO IF NOT #A.
820                 DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
821         END IF.
822         DO IF NOT #B.
823                 DATA LIST NOTABLE END=#B FILE='b.data'/Y 1-10.
824         END IF.
825         DO IF #A AND #B.
826                 END FILE.
827         END IF.
828         END CASE.
829 END INPUT PROGRAM.
830 LIST.
831 @end example
832
833 The above example reads variable X from @file{a.data} and variable Y from
834 @file{b.data}.  If one file is shorter than the other then the missing
835 field is set to the system-missing value alongside the present value for
836 the remaining length of the longer file.
837
838 @c If you change this example, change the regression test3 in
839 @c tests/command/input-program.sh to match.
840 @example
841 INPUT PROGRAM.
842         NUMERIC #A #B.
843
844         DO IF #A.
845                 DATA LIST NOTABLE END=#B FILE='b.data'/X 1-10.
846                 DO IF #B.
847                         END FILE.
848                 ELSE.
849                         END CASE.
850                 END IF.
851         ELSE.
852                 DATA LIST NOTABLE END=#A FILE='a.data'/X 1-10.
853                 DO IF NOT #A.
854                         END CASE.
855                 END IF.
856         END IF.
857 END INPUT PROGRAM.
858 LIST.
859 @end example
860
861 The above example reads data from file @file{a.data}, then from
862 @file{b.data}, and concatenates them into a single active dataset.
863
864 @c If you change this example, change the regression test4 in
865 @c tests/command/input-program.sh to match.
866 @example
867 INPUT PROGRAM.
868         NUMERIC #EOF.
869
870         LOOP IF NOT #EOF.
871                 DATA LIST NOTABLE END=#EOF FILE='a.data'/X 1-10.
872                 DO IF NOT #EOF.
873                         END CASE.
874                 END IF.
875         END LOOP.
876
877         COMPUTE #EOF = 0.
878         LOOP IF NOT #EOF.
879                 DATA LIST NOTABLE END=#EOF FILE='b.data'/X 1-10.
880                 DO IF NOT #EOF.
881                         END CASE.
882                 END IF.
883         END LOOP.
884
885         END FILE.
886 END INPUT PROGRAM.
887 LIST.
888 @end example
889
890 The above example does the same thing as the previous example, in a
891 different way.
892
893 @c If you change this example, make similar changes to the regression
894 @c test5 in tests/command/input-program.sh.
895 @example
896 INPUT PROGRAM.
897         LOOP #I=1 TO 50.
898                 COMPUTE X=UNIFORM(10).
899                 END CASE.
900         END LOOP.
901         END FILE.
902 END INPUT PROGRAM.
903 LIST/FORMAT=NUMBERED.
904 @end example
905
906 The above example causes an active dataset to be created consisting of 50
907 random variates between 0 and 10.
908
909 @node LIST
910 @section LIST
911 @vindex LIST
912
913 @display
914 LIST
915         /VARIABLES=@var{var_list}
916         /CASES=FROM @var{start_index} TO @var{end_index} BY @var{incr_index}
917         /FORMAT=@{UNNUMBERED,NUMBERED@} @{WRAP,SINGLE@}
918 @end display
919
920 The @cmd{LIST} procedure prints the values of specified variables to the
921 listing file.
922
923 The @subcmd{VARIABLES} subcommand specifies the variables whose values are to be
924 printed.  Keyword VARIABLES is optional.  If @subcmd{VARIABLES} subcommand is not
925 specified then all variables in the active dataset are printed.
926
927 The @subcmd{CASES} subcommand can be used to specify a subset of cases to be
928 printed.  Specify @subcmd{FROM} and the case number of the first case to print,
929 @subcmd{TO} and the case number of the last case to print, and @subcmd{BY} and the number
930 of cases to advance between printing cases, or any subset of those
931 settings.  If @subcmd{CASES} is not specified then all cases are printed.
932
933 The @subcmd{FORMAT} subcommand can be used to change the output format.  @subcmd{NUMBERED}
934 will print case numbers along with each case; @subcmd{UNNUMBERED}, the default,
935 causes the case numbers to be omitted.  The @subcmd{WRAP} and @subcmd{SINGLE} settings are
936 currently not used.
937
938 Case numbers start from 1.  They are counted after all transformations
939 have been considered.
940
941 @cmd{LIST} attempts to fit all the values on a single line.  If needed
942 to make them fit, variable names are displayed vertically.  If values
943 cannot fit on a single line, then a multi-line format will be used.
944
945 @cmd{LIST} is a procedure.  It causes the data to be read.
946
947 @node NEW FILE
948 @section NEW FILE
949 @vindex NEW FILE
950
951 @display
952 NEW FILE.
953 @end display
954
955 @cmd{NEW FILE} command clears the dictionary and data from the current
956 active dataset.
957
958 @node PRINT
959 @section PRINT
960 @vindex PRINT
961
962 @display
963 PRINT 
964         [OUTFILE='@var{file_name}']
965         [RECORDS=@var{n_lines}]
966         [@{NOTABLE,TABLE@}]
967         [ENCODING='@var{encoding}']
968         [/[@var{line_no}] @var{arg}@dots{}]
969
970 @var{arg} takes one of the following forms:
971         '@var{string}' [@var{start}]
972         @var{var_list} @var{start}-@var{end} [@var{type_spec}]
973         @var{var_list} (@var{fortran_spec})
974         @var{var_list} *
975 @end display
976
977 The @cmd{PRINT} transformation writes variable data to the listing
978 file or an output file.  @cmd{PRINT} is executed when a procedure
979 causes the data to be read.  Follow @cmd{PRINT} by @cmd{EXECUTE} to
980 print variable data without invoking a procedure (@pxref{EXECUTE}).
981
982 All @cmd{PRINT} subcommands are optional.  If no strings or variables
983 are specified, @cmd{PRINT} outputs a single blank line.
984
985 The @subcmd{OUTFILE} subcommand specifies the file to receive the output.  The
986 file may be a file name as a string or a file handle (@pxref{File
987 Handles}).  If @subcmd{OUTFILE} is not present then output will be sent to
988 @pspp{}'s output listing file.  When @subcmd{OUTFILE} is present, a space is
989 inserted at beginning of each output line, even lines that otherwise
990 would be blank.
991
992 The @subcmd{ENCODING} subcommand may only be used if the
993 @subcmd{OUTFILE} subcommand is also used.  It specifies the character
994 encoding of the file.  @xref{INSERT}, for information on supported
995 encodings.
996
997 The @subcmd{RECORDS} subcommand specifies the number of lines to be output.  The
998 number of lines may optionally be surrounded by parentheses.
999
1000 @subcmd{TABLE} will cause the @cmd{PRINT} command to output a table to the listing file
1001 that describes what it will print to the output file.  @subcmd{NOTABLE}, the
1002 default, suppresses this output table.
1003
1004 Introduce the strings and variables to be printed with a slash
1005 (@samp{/}).  Optionally, the slash may be followed by a number
1006 indicating which output line will be specified.  In the absence of this
1007 line number, the next line number will be specified.  Multiple lines may
1008 be specified using multiple slashes with the intended output for a line
1009 following its respective slash.
1010
1011 Literal strings may be printed.  Specify the string itself.
1012 Optionally the string may be followed by a column number, specifying
1013 the column on the line where the string should start.  Otherwise, the
1014 string will be printed at the current position on the line.
1015
1016 Variables to be printed can be specified in the same ways as available
1017 for @cmd{DATA LIST FIXED} (@pxref{DATA LIST FIXED}).  In addition, a
1018 variable
1019 list may be followed by an asterisk (@samp{*}), which indicates that the
1020 variables should be printed in their dictionary print formats, separated
1021 by spaces.  A variable list followed by a slash or the end of command
1022 will be interpreted the same way.
1023
1024 If a FORTRAN type specification is used to move backwards on the current
1025 line, then text is written at that point on the line, the line will be
1026 truncated to that length, although additional text being added will
1027 again extend the line to that length.
1028
1029 @node PRINT EJECT
1030 @section PRINT EJECT
1031 @vindex PRINT EJECT
1032
1033 @display
1034 PRINT EJECT 
1035         OUTFILE='@var{file_name}'
1036         RECORDS=@var{n_lines}
1037         @{NOTABLE,TABLE@}
1038         /[@var{line_no}] @var{arg}@dots{}
1039
1040 @var{arg} takes one of the following forms:
1041         '@var{string}' [@var{start}-@var{end}]
1042         @var{var_list} @var{start}-@var{end} [@var{type_spec}]
1043         @var{var_list} (@var{fortran_spec})
1044         @var{var_list} *
1045 @end display
1046
1047 @cmd{PRINT EJECT} advances to the beginning of a new output page in
1048 the listing file or output file.  It can also output data in the same
1049 way as @cmd{PRINT}.
1050
1051 All @cmd{PRINT EJECT} subcommands are optional.
1052
1053 Without @subcmd{OUTFILE}, @cmd{PRINT EJECT} ejects the current page in
1054 the listing file, then it produces other output, if any is specified.
1055
1056 With @subcmd{OUTFILE}, @cmd{PRINT EJECT} writes its output to the specified file.
1057 The first line of output is written with @samp{1} inserted in the
1058 first column.  Commonly, this is the only line of output.  If
1059 additional lines of output are specified, these additional lines are
1060 written with a space inserted in the first column, as with @subcmd{PRINT}.
1061
1062 @xref{PRINT}, for more information on syntax and usage.
1063
1064 @node PRINT SPACE
1065 @section PRINT SPACE
1066 @vindex PRINT SPACE
1067
1068 @display
1069 PRINT SPACE [OUTFILE='file_name'] [ENCODING='@var{encoding}'] [n_lines].
1070 @end display
1071
1072 @cmd{PRINT SPACE} prints one or more blank lines to an output file.
1073
1074 The @subcmd{OUTFILE} subcommand is optional.  It may be used to direct output to
1075 a file specified by file name as a string or file handle (@pxref{File
1076 Handles}).  If OUTFILE is not specified then output will be directed to
1077 the listing file.
1078
1079 The @subcmd{ENCODING} subcommand may only be used if @subcmd{OUTFILE}
1080 is also used.  It specifies the character encoding of the file.
1081 @xref{INSERT}, for information on supported encodings.
1082
1083 n_lines is also optional.  If present, it is an expression
1084 (@pxref{Expressions}) specifying the number of blank lines to be
1085 printed.  The expression must evaluate to a nonnegative value.
1086
1087 @node REREAD
1088 @section REREAD
1089 @vindex REREAD
1090
1091 @display
1092 REREAD [FILE=handle] [COLUMN=column] [ENCODING='@var{encoding}'].
1093 @end display
1094
1095 The @cmd{REREAD} transformation allows the previous input line in a
1096 data file
1097 already processed by @cmd{DATA LIST} or another input command to be re-read
1098 for further processing.
1099
1100 The @subcmd{FILE} subcommand, which is optional, is used to specify the file to
1101 have its line re-read.  The file must be specified as the name of a file
1102 handle (@pxref{File Handles}).  If FILE is not specified then the last
1103 file specified on @cmd{DATA LIST} will be assumed (last file specified
1104 lexically, not in terms of flow-of-control).
1105
1106 By default, the line re-read is re-read in its entirety.  With the
1107 @subcmd{COLUMN} subcommand, a prefix of the line can be exempted from
1108 re-reading.  Specify an expression (@pxref{Expressions}) evaluating to
1109 the first column that should be included in the re-read line.  Columns
1110 are numbered from 1 at the left margin.
1111
1112 The @subcmd{ENCODING} subcommand may only be used if the @subcmd{FILE}
1113 subcommand is also used.  It specifies the character encoding of the
1114 file.   @xref{INSERT}, for information on supported encodings.
1115
1116 Issuing @code{REREAD} multiple times will not back up in the data
1117 file.  Instead, it will re-read the same line multiple times.
1118
1119 @node REPEATING DATA
1120 @section REPEATING DATA
1121 @vindex REPEATING DATA
1122
1123 @display
1124 REPEATING DATA
1125         /STARTS=@var{start}-@var{end}
1126         /OCCURS=@var{n_occurs}
1127         /FILE='@var{file_name}'
1128         /LENGTH=@var{length}
1129         /CONTINUED[=@var{cont_start}-@var{cont_end}]
1130         /ID=@var{id_start}-@var{id_end}=@var{id_var}
1131         /@{TABLE,NOTABLE@}
1132         /DATA=@var{var_spec}@dots{}
1133
1134 where each @var{var_spec} takes one of the forms
1135         @var{var_list} @var{start}-@var{end} [@var{type_spec}]
1136         @var{var_list} (@var{fortran_spec})
1137 @end display
1138
1139 @cmd{REPEATING DATA} parses groups of data repeating in
1140 a uniform format, possibly with several groups on a single line.  Each
1141 group of data corresponds with one case.  @cmd{REPEATING DATA} may only be
1142 used within an @cmd{INPUT PROGRAM} structure (@pxref{INPUT PROGRAM}).
1143 When used with @cmd{DATA LIST}, it
1144 can be used to parse groups of cases that share a subset of variables
1145 but differ in their other data.
1146
1147 The @subcmd{STARTS} subcommand is required.  Specify a range of columns, using
1148 literal numbers or numeric variable names.  This range specifies the
1149 columns on the first line that are used to contain groups of data.  The
1150 ending column is optional.  If it is not specified, then the record
1151 width of the input file is used.  For the inline file (@pxref{BEGIN
1152 DATA}) this is 80 columns; for a file with fixed record widths it is the
1153 record width; for other files it is 1024 characters by default.
1154
1155 The @subcmd{OCCURS} subcommand is required.  It must be a number or the name of a
1156 numeric variable.  Its value is the number of groups present in the
1157 current record.
1158
1159 The @subcmd{DATA} subcommand is required.  It must be the last subcommand
1160 specified.  It is used to specify the data present within each repeating
1161 group.  Column numbers are specified relative to the beginning of a
1162 group at column 1.  Data is specified in the same way as with @cmd{DATA LIST
1163 FIXED} (@pxref{DATA LIST FIXED}).
1164
1165 All other subcommands are optional.
1166
1167 FILE specifies the file to read, either a file name as a string or a
1168 file handle (@pxref{File Handles}).  If FILE is not present then the
1169 default is the last file handle used on @cmd{DATA LIST} (lexically, not in
1170 terms of flow of control).
1171
1172 By default @cmd{REPEATING DATA} will output a table describing how it will
1173 parse the input data.  Specifying @subcmd{NOTABLE} will disable this behavior;
1174 specifying TABLE will explicitly enable it.
1175
1176 The @subcmd{LENGTH} subcommand specifies the length in characters of each group.
1177 If it is not present then length is inferred from the @subcmd{DATA} subcommand.
1178 LENGTH can be a number or a variable name.
1179
1180 Normally all the data groups are expected to be present on a single
1181 line.  Use the @subcmd{CONTINUED} command to indicate that data can be continued
1182 onto additional lines.  If data on continuation lines starts at the left
1183 margin and continues through the entire field width, no column
1184 specifications are necessary on @subcmd{CONTINUED}.  Otherwise, specify the
1185 possible range of columns in the same way as on STARTS.
1186
1187 When data groups are continued from line to line, it is easy
1188 for cases to get out of sync through careless hand editing.  The
1189 @subcmd{ID} subcommand allows a case identifier to be present on each line of
1190 repeating data groups.  @cmd{REPEATING DATA} will check for the same
1191 identifier on each line and report mismatches.  Specify the range of
1192 columns that the identifier will occupy, followed by an equals sign
1193 (@samp{=}) and the identifier variable name.  The variable must already
1194 have been declared with @cmd{NUMERIC} or another command.
1195
1196 @cmd{REPEATING DATA} should be the last command given within an
1197 @cmd{INPUT PROGRAM}.  It should not be enclosed within a @cmd{LOOP}
1198 structure (@pxref{LOOP}).  Use @cmd{DATA LIST} before, not after,
1199 @cmd{REPEATING DATA}.
1200
1201 @node WRITE
1202 @section WRITE
1203 @vindex WRITE
1204
1205 @display
1206 WRITE 
1207         OUTFILE='@var{file_name}'
1208         RECORDS=@var{n_lines}
1209         @{NOTABLE,TABLE@}
1210         /[@var{line_no}] @var{arg}@dots{}
1211
1212 @var{arg} takes one of the following forms:
1213         '@var{string}' [@var{start}-@var{end}]
1214         @var{var_list} @var{start}-@var{end} [@var{type_spec}]
1215         @var{var_list} (@var{fortran_spec})
1216         @var{var_list} *
1217 @end display
1218
1219 @code{WRITE} writes text or binary data to an output file.  
1220
1221 @xref{PRINT}, for more information on syntax and usage.  @cmd{PRINT}
1222 and @cmd{WRITE} differ in only a few ways:
1223
1224 @itemize @bullet
1225 @item
1226 @cmd{WRITE} uses write formats by default, whereas @cmd{PRINT} uses
1227 print formats.
1228
1229 @item
1230 @cmd{PRINT} inserts a space between variables unless a format is
1231 explicitly specified, but @cmd{WRITE} never inserts space between
1232 variables in output.
1233
1234 @item
1235 @cmd{PRINT} inserts a space at the beginning of each line that it
1236 writes to an output file (and @cmd{PRINT EJECT} inserts @samp{1} at
1237 the beginning of each line that should begin a new page), but
1238 @cmd{WRITE} does not.
1239
1240 @item
1241 @cmd{PRINT} outputs the system-missing value according to its
1242 specified output format, whereas @cmd{WRITE} outputs the
1243 system-missing value as a field filled with spaces.  Binary formats
1244 are an exception.
1245 @end itemize