Next: wtanova() Up: MacAnova Help File Previous: write()   Contents


writedata(fileName,x1,x2,... [,missing:M] [, putNames:F] \
  [,fieldwidth:w  or  format:fmt]), CHARACTER scalar fileName, vectors
  x1, x2, ..., all with same length, CHARACTER scalars M, fmt,
  integer w > 0
writedata(x1,x2,..., keep:T [,missing:M] [, putnames:F] \
  [,fieldwidth:w  or  format:fmt])

Keywords: output
writedata() is a macro designed to write one or more data vectors of
arbitrary as columns of a data file.  By default, columns are headed by
the variable names so reading the file using readdata() should restore
the variables.  Optionally, writedata() can return a CHARACTER scalar
containing an image of the file instead of writing it.

writedata(fileName,x1,x2,...) writes data vectors x1, x2, ... as columns
in the file named by CHARACTER scalar fileName.

x1, x2, ... must be vectors of any type, REAL, LOGICAL or CHARACTER.  If
any vector is a factor and has row labels such that all cases with a
factor level have the same label, the row labels are written instead of
the factor levels.

REAL data are formatted using the current default format as returned
by getoptions(format:T), except that integer values are written as
integers with no decimal point.

CHARACTER data is written right justified in a field whose width is
taken from the default format.

LOGICAL data are translated to "T" or "F" and then written like

MISSING values are written as "?" unless keyword 'missing' provides
another string; see below.

If a data vector is specified by a keyword phrase (x1:X[,1], for
example), the keyword is used as the vector name.  For this usage, the
keyword may not be 'keep', 'new', 'fieldwidth' or 'missing'.

Any data already in the file is destroyed unless 'new:F' is an
additional argument.

writedata(x1,x2,...,keep:T) acts similarly, except that no file is
written.  Instead, what would be written is returned as a CHARACTER
scalar to be assigned to a variable or CLIPBOARD.

writedata(fileName, x1, x2, ..., missing:M) and writedata(x1, x2, ...,
keep:T,missing:M) do the same, except that CHARACTER scalar M (for
example, "NA" or "*") is used instead of "?" for MISSING values.

By default, each column has the same width.  You can suppress this
behavior, so there is minimual space between columns, by keyword
'format'; see below.

writedata(fileName, x1, x2, ..., putnames:F) and writedata(x1, x2, ...,
keep:T, putnames:F) do the same, except that no line of column headers
is written or returned.

When 'format:Fmt' is an argument, REAL values are written using format
Fmt.  Fmt must be a CHARACTER scalar which is a legal value for print()
keyword 'format'.  For details, see subtopic
print:"details_on_format_keyword".  If Fmt is of the form "w.dg" or
"w.df", where w and d are integers, each column will have width at least
w.  If Fmt is of the form ".dg" or ".df", there will be minimal space
between columns and columns will probably not be straight.

When fieldwidth:w is an argument, where w is a positive integer, columns
will be w characters wide and the format will be "w.dg", where d =
max(w-7,0).  You can't use 'fieldwidth' with 'format'.

See also readdata(), clipwritedat(), print(), 'keywords', 'files'

Gary Oehlert 2003-01-15