cairo-fsm: Remove dead code in xr_fsm_create().
[pspp.git] / doc / variables.texi
blob5cc1a23620a9d530fa142b0db15675f93f14c47c
1 @c PSPP - a program for statistical analysis.
2 @c Copyright (C) 2017, 2020 Free Software Foundation, Inc.
3 @c Permission is granted to copy, distribute and/or modify this document
4 @c under the terms of the GNU Free Documentation License, Version 1.3
5 @c or any later version published by the Free Software Foundation;
6 @c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
7 @c A copy of the license is included in the section entitled "GNU
8 @c Free Documentation License".
9 @c
10 @node Manipulating Variables
11 @chapter Manipulating Variables
12 @cindex Variables
14 Every value in a dataset is associated with a @dfn{variable}.
15 Variables describe what the values represent and properties of those values,
16 such as the format in which they should be displayed, whether they are numeric
17 or alphabetic and how missing values should be represented.
18 There are several utility commands for examining and adjusting variables.
20 @menu
21 * DISPLAY::                     Display information about the active dataset.
22 * NUMERIC::                     Create new numeric variables.
23 * STRING::                      Create new string variables.
24 * MODIFY VARS::                 Rename, reorder, and drop variables.
25 * RENAME VARIABLES::            Rename variables.
26 * SORT VARIABLES::              Reorder variables.
27 * DELETE VARIABLES::            Delete variables.
28 * VARIABLE LABELS::             Set variable labels for variables.
29 * PRINT FORMATS::               Set variable print formats.
30 * WRITE FORMATS::               Set variable write formats.
31 * FORMATS::                     Set print and write formats.
32 * VALUE LABELS::                Set value labels for variables.
33 * ADD VALUE LABELS::            Add value labels to variables.
34 * MISSING VALUES::              Set missing values for variables.
35 * VARIABLE ATTRIBUTE::          Set custom attributes on variables.
36 * VARIABLE ALIGNMENT::          Set the alignment for display.
37 * VARIABLE WIDTH::              Set the display width.
38 * VARIABLE LEVEL::              Set the measurement level.
39 * VARIABLE ROLE::               Set the role that a variable fills in analysis.
40 * VECTOR::                      Declare an array of variables.
41 * MRSETS::                      Add, modify, and list multiple response sets.
42 * LEAVE::                       Don't clear variables between cases.
43 @end menu
45 @node DISPLAY
46 @section DISPLAY
47 @vindex DISPLAY
49 The @cmd{DISPLAY} command displays information about the variables in the active dataset.
50 A variety of different forms of information can be requested.
51 By default, all variables in the active dataset are displayed.  However you can select
52 variables of interest using the @subcmd{/VARIABLES} subcommand.
54 @display
55 DISPLAY [SORTED] NAMES [[/VARIABLES=]@var{var_list}].
56 DISPLAY [SORTED] INDEX [[/VARIABLES=]@var{var_list}].
57 DISPLAY [SORTED] LABELS [[/VARIABLES=]@var{var_list}].
58 DISPLAY [SORTED] VARIABLES [[/VARIABLES=]@var{var_list}].
59 DISPLAY [SORTED] DICTIONARY [[/VARIABLES=]@var{var_list}].
60 DISPLAY [SORTED] SCRATCH [[/VARIABLES=]@var{var_list}].
61 DISPLAY [SORTED] ATTRIBUTES [[/VARIABLES=]@var{var_list}].
62 DISPLAY [SORTED] @@ATTRIBUTES [[/VARIABLES=]@var{var_list}].
63 DISPLAY [SORTED] VECTORS.
64 @end display
66 The following keywords primarily cause information about variables to
67 be displayed.  With these keywords, by default information is
68 displayed about all variable in the active dataset, in the order that
69 variables occur in the active dataset dictionary.  The @subcmd{SORTED} keyword
70 causes output to be sorted alphabetically by variable name.
72 @table @asis
73 @item NAMES
74 The variables' names are displayed.
76 @item INDEX
77 The variables' names are displayed along with a value describing their
78 position within the active dataset dictionary.
80 @item LABELS
81 Variable names, positions, and variable labels are displayed.
83 @item VARIABLES
84 Variable names, positions, print and write formats, and missing values
85 are displayed.
87 @item DICTIONARY
88 Variable names, positions, print and write formats, missing values,
89 variable labels, and value labels are displayed.
91 @item SCRATCH
92 Variable names are displayed, for scratch variables only (@pxref{Scratch
93 Variables}).
95 @item ATTRIBUTES
96 @itemx @@ATTRIBUTES
97 Datafile and variable attributes are displayed.
98 The first form of the command omits those attributes
99 whose names begin with @code{@@} or @code{$@@}.
100 In the second for, all datafile and variable attributes are displayed.
101 @end table
103 With the @code{VECTOR} keyword, @cmd{DISPLAY} lists all the currently
104 declared vectors.  If the @subcmd{SORTED} keyword is given, the vectors are
105 listed in alphabetical order; otherwise, they are listed in textual
106 order of definition within the @pspp{} syntax file.
108 For related commands, see @ref{DISPLAY DOCUMENTS} and @ref{DISPLAY
109 FILE LABEL}.
111 @node NUMERIC
112 @section NUMERIC
113 @vindex NUMERIC
115 @cmd{NUMERIC} explicitly declares new numeric variables, optionally
116 setting their output formats.
118 @display
119 NUMERIC @var{var_list} [(@var{fmt_spec})] [/@var{var_list} [(@var{fmt_spec})]]@dots{}
120 @end display
122 Specify the names of the new numeric variables as @var{var_list}.  If
123 you wish to set the variables' output formats, follow their names by
124 an output format specification in parentheses (@pxref{Input and Output
125 Formats}); otherwise, the default is F8.2.
127 Variables created with @cmd{NUMERIC} are initialized to the
128 system-missing value.
130 @node STRING
131 @section STRING
132 @vindex STRING
134 @cmd{STRING} creates new string variables.
136 @display
137 STRING @var{var_list} (@var{fmt_spec}) [/@var{var_list} (@var{fmt_spec})] [@dots{}].
138 @end display
140 Specify a list of names for the variable you want to create,
141 followed by the desired output format specification in
142 parentheses (@pxref{Input and Output Formats}).
143 Variable widths are
144 implicitly derived from the specified output formats.
145 The created variables will be initialized to spaces.
147 If you want to create several variables with  distinct
148 output formats, you can either use two or more separate @cmd{STRING} commands,
149 or you can specify further variable list and format specification pairs, each separated
150 from the previous by a slash (@samp{/}).
152 The following example is one way to create three string variables; Two of the
153 variables have format A24 and the other A80:
154 @example
155 STRING firstname lastname (A24) / address (A80).
156 @end example
158 @noindent Here is another way to achieve the same result:
159 @example
160 STRING firstname lastname (A24).
161 STRING address (A80).
162 @end example
164 @noindent @dots{} and here is yet another way:
166 @example
167 STRING firstname (A24).
168 STRING lastname (A24).
169 STRING address (A80).
170 @end example
172 @node MODIFY VARS
173 @section MODIFY VARS
174 @vindex MODIFY VARS
176 You can use @cmd{MODIFY VARS} to reorder, rename, or delete variables.
178 @display
179 MODIFY VARS
180         /REORDER=@{FORWARD,BACKWARD@} @{POSITIONAL,ALPHA@} (@var{var_list})@dots{}
181         /RENAME=(@var{old_names}=@var{new_names})@dots{}
182         /@{DROP,KEEP@}=@var{var_list}
183         /MAP
184 @end display
186 At least one subcommand must be specified, and no subcommand may be
187 specified more than once.  @subcmd{DROP} and @subcmd{KEEP} may not both
188 be specified.
190 The @subcmd{REORDER} subcommand changes the order of variables in the active
191 dataset.  Specify one or more lists of variable names in parentheses.  By
192 default, each list of variables is rearranged into the specified order.
193 To put the variables into the reverse of the specified order, put
194 keyword @subcmd{BACKWARD} before the parentheses.  To put them into alphabetical
195 order in the dictionary, specify keyword @subcmd{ALPHA} before the parentheses.
196 @subcmd{BACKWARD} and @subcmd{ALPHA} may also be combined.
198 To rename variables in the active dataset, specify @subcmd{RENAME}, an equals sign
199 (@samp{=}), and lists of the old variable names and new variable names
200 separated by another equals sign within parentheses.  There must be the
201 same number of old and new variable names.  Each old variable is renamed to
202 the corresponding new variable name.  Multiple parenthesized groups of
203 variables may be specified.
205 The @subcmd{DROP} subcommand deletes a specified list of variables
206 from the active dataset.  @cmd{MODIFY VARS} may not be used to delete
207 all variables from the dictionary; use @cmd{NEW FILE} to do that
208 (@pxref{NEW FILE}).
210 The @subcmd{KEEP} subcommand keeps the specified list of variables in the active
211 dataset.  Any unlisted variables are deleted from the active dataset.
213 @subcmd{MAP} is currently ignored.
215 If either @subcmd{DROP} or @subcmd{KEEP} is specified, the data is read;
216 otherwise it is not.
218 @cmd{MODIFY VARS} may not be specified following @cmd{TEMPORARY}
219 (@pxref{TEMPORARY}).
221 @node RENAME VARIABLES
222 @section RENAME VARIABLES
223 @vindex RENAME VARIABLES
225 @cmd{RENAME VARIABLES} changes the names of variables in the active
226 dataset.
228 @display
229 RENAME VARIABLES (@var{old_names}=@var{new_names})@dots{} .
230 @end display
232 Specify lists of the old variable names and new
233 variable names, separated by an equals sign (@samp{=}), within
234 parentheses.  There must be the same number of old and new variable
235 names.  Each old variable is renamed to the corresponding new variable
236 name.  Multiple parenthesized groups of variables may be specified.
237 When the old and new variable names contain only a single variable name,
238 the parentheses are optional.
240 @cmd{RENAME VARIABLES} takes effect immediately.  It does not cause the data
241 to be read.
243 @cmd{RENAME VARIABLES} may not be specified following @cmd{TEMPORARY}
244 (@pxref{TEMPORARY}).
246 @node SORT VARIABLES
247 @section SORT VARIABLES
248 @vindex SORT VARIABLES
250 @cmd{SORT VARIABLES} reorders the variables in the active dataset's dictionary
251 according to a chosen sort key.
253 @display
254 SORT VARIABLES [BY]
255     (NAME | TYPE | FORMAT | LABEL | VALUES | MISSING | MEASURE
256      | ROLE | COLUMNS | ALIGNMENT | ATTRIBUTE @var{name})
257     [(D)].
258 @end display
260 The main specification is one of the following identifiers, which
261 determines how the variables are sorted:
263 @table @asis
264 @item NAME
265 Sorts the variables according to their names, in a case-insensitive
266 fashion.  However, when variable names differ only in a number at the
267 end, they are sorted numerically.  For example, @code{VAR5} is sorted
268 before @code{VAR400} even though @samp{4} precedes @samp{5}.
270 @item TYPE
271 Sorts numeric variables before string variables, and shorter string
272 variables before longer ones.
274 @item FORMAT
275 Groups variables by print format; within a format, sorts narrower
276 formats before wider ones; with the same format and width, sorts fewer
277 decimal places before more decimal places.
278 @xref{FORMATS}.
280 @item LABEL
281 Sorts variables without a variable label before those with one.
282 @xref{VARIABLE LABELS}.
284 @item VALUES
285 Sorts variables without value labels before those with some.
286 @xref{VALUE LABELS}.
288 @item MISSING
289 Sorts variables without missing values before those with some.
290 @xref{MISSING VALUES}.
292 @item MEASURE
293 Sorts nominal variables first, followed by ordinal variables, followed
294 by scale variables.  @xref{VARIABLE LEVEL}.
296 @item ROLE
297 Groups variables according to their role.  @xref{VARIABLE ROLE}.
299 @item COLUMNS
300 Sorts variables in ascending display width.  @xref{VARIABLE WIDTH}.
302 @item ALIGNMENT
303 Sorts variables according to their alignment, first left-aligned, then
304 right-aligned, then centered.  @xref{VARIABLE ALIGNMENT}.
306 @item ATTRIBUTE @var{name}
307 Sorts variables according to the first value of their @var{name}
308 attribute.  Variables without attribute are sorted first.
309 @xref{VARIABLE ATTRIBUTE}.
310 @end table
312 Only one sort criterion can be specified.  The sort is ``stable,'' so
313 to sort on multiple criteria one may perform multiple sorts.  For
314 example, the following will sort primarily based on alignment, with
315 variables that have the same alignment ordered based on display width:
317 @example
318 SORT VARIABLES BY COLUMNS.
319 SORT VARIABLES BY ALIGNMENT.
320 @end example
322 Specify @code{(D)} to reverse the sort order.
324 @node DELETE VARIABLES
325 @section DELETE VARIABLES
326 @vindex DELETE VARIABLES
328 @cmd{DELETE VARIABLES} deletes the specified variables from the dictionary.
330 @display
331 DELETE VARIABLES @var{var_list}.
332 @end display
334 @cmd{DELETE VARIABLES} should not be used after defining transformations
335 but before executing a procedure.  If it is used in such a context, it
336 causes the data to be read.  If it is used while @cmd{TEMPORARY} is in
337 effect, it causes the temporary transformations to become permanent.
339 @cmd{DELETE VARIABLES} may not be used to delete all variables from the
340 dictionary; use @cmd{NEW FILE} to do that (@pxref{NEW FILE}).
342 @node VARIABLE LABELS
343 @section VARIABLE LABELS
344 @vindex VARIABLE LABELS
346 In addition to a variable's name, each variable can have a @dfn{label}.
347 Whereas the name is limited to certain constraints (@pxref{Attributes}) a variable's
348 label has no such constraints.
349 Typically, the names are concise, easy to type mnemonics for the variable
350 and the labels are longer, more verbose descriptions.
352 @display
353 VARIABLE LABELS
354         @var{var_list} '@var{var_label}'
355         [ /@var{var_list} '@var{var_label}']
356         .
357         .
358         .
359         [ /@var{var_list} '@var{var_label}']
360 @end display
362 @cmd{VARIABLE LABELS} associates explanatory names
363 with variables.  This name, called a @dfn{variable label}, is displayed by
364 statistical procedures.
366 To assign a variable label to a group of variables, specify a
367 list of variable names and the variable label as a string.
368 To assign different labels to different variables in the same command,
369 precede the subsequent variable list with a slash (@samp{/}).
371 @node PRINT FORMATS
372 @section PRINT FORMATS
373 @vindex PRINT FORMATS
375 @display
376 PRINT FORMATS @var{var_list} (@var{fmt_spec}) [@var{var_list} (@var{fmt_spec})]@dots{}.
377 @end display
379 @cmd{PRINT FORMATS} sets the print formats for the specified
380 variables to the specified format specification.
382 Its syntax is identical to that of @cmd{FORMATS} (@pxref{FORMATS}),
383 but @cmd{PRINT FORMATS} sets only print formats, not write formats.
385 @node WRITE FORMATS
386 @section WRITE FORMATS
387 @vindex WRITE FORMATS
389 @display
390 WRITE FORMATS @var{var_list} (@var{fmt_spec}) [@var{var_list} (@var{fmt_spec})]@dots{}.
391 @end display
393 @cmd{WRITE FORMATS} sets the write formats for the specified variables
394 to the specified format specification.  Its syntax is identical to
395 that of @cmd{FORMATS} (@pxref{FORMATS}), but @cmd{WRITE FORMATS} sets only
396 write formats, not print formats.
398 @node FORMATS
399 @section FORMATS
400 @vindex FORMATS
402 @display
403 FORMATS @var{var_list} (@var{fmt_spec}) [@var{var_list} (@var{fmt_spec})]@dots{}.
404 @end display
406 @cmd{FORMATS} set both print and write formats for the specified
407 variables to the specified format specification.
408 @xref{Input and Output Formats}.
410 Specify a list of variables followed by a format specification in
411 parentheses.  The print and write formats of the specified variables
412 will be changed.  All of the variables listed together must have
413 the same type and, for string variables, the same width.
415 Additional lists of variables and formats may be included following
416 the first one.
418 @cmd{FORMATS} takes effect immediately.  It is not affected by
419 conditional and looping structures such as @cmd{DO IF} or @cmd{LOOP}.
421 @node VALUE LABELS
422 @section VALUE LABELS
423 @vindex VALUE LABELS
425 The values of a variable can be associated with an arbitrary text string.
426 In this way, a short value can stand for a longer, more descriptive label.
428 Both numeric and string variables can be given labels.  For string
429 variables, the values are case-sensitive, so that, for example, a
430 capitalized value and its lowercase variant would have to be labeled
431 separately if both are present in the data.
433 @display
434 VALUE LABELS
435         /@var{var_list} @var{value} '@var{label}' [@var{value} '@var{label}']@dots{}
436 @end display
438 @cmd{VALUE LABELS} allows values of variables to be associated with labels.
440 To set up value labels for one or more variables, specify the
441 variable names after a slash (@samp{/}), followed by a list of values
442 and their associated labels, separated by spaces.
444 Value labels in output are normally broken into lines automatically.
445 Put @samp{\n} in a label string to force a line break at that point.
446 The label may still be broken into lines at additional points.
448 Before @cmd{VALUE LABELS} is executed, any existing value labels
449 are cleared from the variables specified.  Use @cmd{ADD VALUE LABELS}
450 (@pxref{ADD VALUE LABELS}) to add value labels without clearing those
451 already present.
453 @node ADD VALUE LABELS
454 @section ADD VALUE LABELS
455 @vindex ADD VALUE LABELS
457 @cmd{ADD VALUE LABELS} has the same syntax and purpose as @cmd{VALUE
458 LABELS} (@pxref{VALUE LABELS}), but it does not clear value
459 labels from the variables before adding the ones specified.
461 @display
462 ADD VALUE LABELS
463         /@var{var_list} @var{value} '@var{label}' [@var{value} '@var{label}']@dots{}
464 @end display
467 @node MISSING VALUES
468 @section MISSING VALUES
469 @vindex MISSING VALUES
471 In many situations the data available for analysis is incomplete and a placeholder
472 must be used in place of a value to indicate that the value is unknown.  One way
473 that missing values are represented is through the $SYSMIS variable
474 (@pxref{System Variables}).  Another, more flexible way is through
475 @dfn{user-missing values} which are determined on a per variable basis.
477 The @cmd{MISSING VALUES} command sets user-missing values for variables.
479 @display
480 MISSING VALUES @var{var_list} (@var{missing_values}).
482 where @var{missing_values} takes one of the following forms:
483         @var{num1}
484         @var{num1}, @var{num2}
485         @var{num1}, @var{num2}, @var{num3}
486         @var{num1} THRU @var{num2}
487         @var{num1} THRU @var{num2}, @var{num3}
488         @var{string1}
489         @var{string1}, @var{string2}
490         @var{string1}, @var{string2}, @var{string3}
491 As part of a range, @subcmd{LO} or @subcmd{LOWEST} may take the place of @var{num1};
492 @subcmd{HI} or @subcmd{HIGHEST} may take the place of @var{num2}.
493 @end display
495 @cmd{MISSING VALUES} sets user-missing values for numeric and string
496 variables.  Long string variables may have missing values, but
497 characters after the first 8 bytes of the missing value must be
498 spaces.
500 Specify a list of variables, followed by a list of their user-missing
501 values in parentheses.  Up to three discrete values may be given, or,
502 for numeric variables only, a range of values optionally accompanied by
503 a single discrete value.  Ranges may be open-ended on one end, indicated
504 through the use of the
505 keyword @subcmd{LO} or @subcmd{LOWEST} or @subcmd{HI} or @subcmd{HIGHEST}.
507 The @cmd{MISSING VALUES} command takes effect immediately.  It is not
508 affected by conditional and looping constructs such as @cmd{DO IF} or
509 @cmd{LOOP}.
511 @node VARIABLE ATTRIBUTE
512 @section VARIABLE ATTRIBUTE
513 @vindex VARIABLE ATTRIBUTE
515 @cmd{VARIABLE ATTRIBUTE} adds, modifies, or removes user-defined
516 attributes associated with variables in the active dataset.  Custom
517 variable attributes are not interpreted by @pspp{}, but they are saved as
518 part of system files and may be used by other software that reads
519 them.
521 @display
522 VARIABLE ATTRIBUTE
523          VARIABLES=@var{var_list}
524          ATTRIBUTE=@var{name}('@var{value}') [@var{name}('@var{value}')]@dots{}
525          ATTRIBUTE=@var{name}@b{[}@var{index}@b{]}('@var{value}') [@var{name}@b{[}@var{index}@b{]}('@var{value}')]@dots{}
526          DELETE=@var{name} [@var{name}]@dots{}
527          DELETE=@var{name}@b{[}@var{index}@b{]} [@var{name}@b{[}@var{index}@b{]}]@dots{}
528 @end display
530 The required @subcmd{VARIABLES} subcommand must come first.  Specify the
531 variables to which the following @subcmd{ATTRIBUTE} or @subcmd{DELETE} subcommand
532 should apply.
534 Use the @subcmd{ATTRIBUTE} subcommand to add or modify custom variable
535 attributes.  Specify the name of the attribute as an identifier
536 (@pxref{Tokens}), followed by the desired value, in parentheses, as a
537 quoted string.  The specified attributes are then added or modified in
538 the variables specified on @subcmd{VARIABLES}.  Attribute names that begin with
539 @code{$} are reserved for @pspp{}'s internal use, and attribute names
540 that begin with @code{@@} or @code{$@@} are not displayed by most @pspp{}
541 commands that display other attributes.  Other attribute names are not
542 treated specially.
544 Attributes may also be organized into arrays.  To assign to an array
545 element, add an integer array index enclosed in square brackets
546 (@code{[} and @code{]}) between the attribute name and value.  Array
547 indexes start at 1, not 0.  An attribute array that has a single
548 element (number 1) is not distinguished from a non-array attribute.
550 Use the @subcmd{DELETE} subcommand to delete an attribute from the variable
551 specified on @subcmd{VARIABLES}.  Specify an attribute name by itself to delete
552 an entire attribute, including all array elements for attribute
553 arrays.  Specify an attribute name followed by an array index in
554 square brackets to delete a single element of an attribute array.  In
555 the latter case, all the array elements numbered higher than the
556 deleted element are shifted down, filling the vacated position.
558 To associate custom attributes with the entire active dataset, instead of
559 with particular variables, use @cmd{DATAFILE ATTRIBUTE} (@pxref{DATAFILE ATTRIBUTE}) instead.
561 @cmd{VARIABLE ATTRIBUTE} takes effect immediately.  It is not affected
562 by conditional and looping structures such as @cmd{DO IF} or
563 @cmd{LOOP}.
565 @node VARIABLE ALIGNMENT
566 @section VARIABLE ALIGNMENT
567 @vindex VARIABLE ALIGNMENT
569 @cmd{VARIABLE ALIGNMENT} sets the alignment of variables for display editing
570 purposes.   It  does not affect the display of variables in the @pspp{} output.
572 @display
573 VARIABLE ALIGNMENT
574         @var{var_list} ( LEFT | RIGHT | CENTER )
575         [ /@var{var_list} ( LEFT | RIGHT | CENTER ) ]
576         .
577         .
578         .
579         [ /@var{var_list} ( LEFT | RIGHT | CENTER ) ]
580 @end display
582 @node VARIABLE WIDTH
583 @section VARIABLE WIDTH
584 @vindex VARIABLE WIDTH
585 @display
586 VARIABLE WIDTH
587         @var{var_list} (width)
588         [ /@var{var_list} (width) ]
589         .
590         .
591         .
592         [ /@var{var_list} (width) ]
593 @end display
595 @cmd{VARIABLE WIDTH} sets the column width of variables for display editing
596 purposes.   It does not affect the display of variables in the @pspp{} output.
599 @node VARIABLE LEVEL
600 @section VARIABLE LEVEL
601 @vindex VARIABLE LEVEL
602 @display
603 VARIABLE LEVEL
604         @var{var_list} ( SCALE | NOMINAL | ORDINAL )
605         [ /@var{var_list} ( SCALE | NOMINAL | ORDINAL ) ]
606         .
607         .
608         .
609         [ /@var{var_list} ( SCALE | NOMINAL | ORDINAL ) ]
610 @end display
612 @cmd{VARIABLE LEVEL} sets the measurement level of  variables.
613 Currently, this has no effect except for certain third party software.
616 @node VARIABLE ROLE
617 @section VARIABLE ROLE
618 @vindex VARIABLE ROLE
619 @display
620 VARIABLE ROLE
621         /@var{role} @var{var_list}
622         [/@var{role} @var{var_list}]@dots{}
623 @end display
625 @cmd{VARIABLE ROLE} sets the intended role of a variable for use in
626 dialog boxes in graphical user interfaces.  Each @var{role} specifies
627 one of the following roles for the variables that follow it:
629 @table @code
630 @item INPUT
631 An input variable, such as an independent variable.
633 @item TARGET
634 An output variable, such as an dependent variable.
636 @item BOTH
637 A variable used for input and output.
639 @item NONE
640 No role assigned.  (This is a variable's default role.)
642 @item PARTITION
643 Used to break the data into groups for testing.
645 @item SPLIT
646 No meaning except for certain third party software.  (This role's
647 meaning is unrelated to @cmd{SPLIT FILE}.)
648 @end table
650 The PSPPIRE GUI does not yet use variable roles as intended.
652 @node VECTOR
653 @section VECTOR
654 @vindex VECTOR
656 @display
657 Two possible syntaxes:
658         VECTOR @var{vec_name}=@var{var_list}.
659         VECTOR @var{vec_name_list}(@var{count} [@var{format}]).
660 @end display
662 @cmd{VECTOR} allows a group of variables to be accessed as if they
663 were consecutive members of an array with a vector(index) notation.
665 To make a vector out of a set of existing variables, specify a name
666 for the vector followed by an equals sign (@samp{=}) and the variables
667 to put in the vector.  The variables must be all numeric or all
668 string, and string variables must have the same width.
670 To make a vector and create variables at the same time, specify one or
671 more vector names followed by a count in parentheses.  This will
672 create variables named @code{@var{vec}1} through
673 @code{@var{vec}@var{count}}.  By default, the new variables are
674 numeric with format F8.2, but an alternate format may be specified
675 inside the parentheses before or after the count and separated from it
676 by white space or a comma.  With a string format such as A8, the
677 variables will be string variables; with a numeric format, they will
678 be numeric.  Variable names including the suffixes may not exceed 64
679 characters in length, and none of the variables may exist prior to
680 @cmd{VECTOR}.
682 Vectors created with @cmd{VECTOR} disappear after any procedure or
683 procedure-like command is executed.  The variables contained in the
684 vectors remain, unless they are scratch variables (@pxref{Scratch
685 Variables}).
687 Variables within a vector may be referenced in expressions using
688 @code{vector(index)} syntax.
690 @node MRSETS
691 @section MRSETS
692 @vindex MRSETS
694 @cmd{MRSETS} creates, modifies, deletes, and displays multiple
695 response sets.  A multiple response set is a set of variables that
696 represent multiple responses to a survey question.
698 Multiple responses are represented in one of the two following ways:
700 @itemize @bullet
701 @item
702 A @dfn{multiple dichotomy set} is analogous to a survey question with
703 a set of checkboxes.  Each variable in the set is treated in a Boolean
704 fashion: one value (the "counted value") means that the box was
705 checked, and any other value means that it was not.
707 @item
708 A @dfn{multiple category set} represents a survey question where the
709 respondent is instructed to list up to @var{n} choices.  Each variable
710 represents one of the responses.
711 @end itemize
713 @display
714 MRSETS
715     /MDGROUP NAME=@var{name} VARIABLES=@var{var_list} VALUE=@var{value}
716      [CATEGORYLABELS=@{VARLABELS,COUNTEDVALUES@}]
717      [@{LABEL='@var{label}',LABELSOURCE=VARLABEL@}]
719     /MCGROUP NAME=@var{name} VARIABLES=@var{var_list} [LABEL='@var{label}']
721     /DELETE NAME=@{[@var{names}],ALL@}
723     /DISPLAY NAME=@{[@var{names}],ALL@}
724 @end display
727 Any number of subcommands may be specified in any order.
729 The @subcmd{MDGROUP} subcommand creates a new multiple dichotomy set or
730 replaces an existing multiple response set.  The @subcmd{NAME},
731 @subcmd{VARIABLES}, and
732 @subcmd{VALUE} specifications are required.  The others are optional:
734 @itemize @bullet
735 @item
736 @var{NAME} specifies the name used in syntax for the new multiple dichotomy
737 set.  The name must begin with @samp{$}; it must otherwise follow the
738 rules for identifiers (@pxref{Tokens}).
740 @item
741 @subcmd{VARIABLES} specifies the variables that belong to the set.  At least
742 two variables must be specified.  The variables must be all string or
743 all numeric.
745 @item
746 @subcmd{VALUE} specifies the counted value.  If the variables are numeric, the
747 value must be an integer.  If the variables are strings, then the
748 value must be a string that is no longer than the shortest of the
749 variables in the set (ignoring trailing spaces).
751 @item
752 @subcmd{CATEGORYLABELS} optionally specifies the source of the labels for each
753 category in the set:
755 @itemize @minus
756 @item
757 @subcmd{VARLABELS}, the default, uses variable labels or, for variables without
758 variable labels, variable names.  @pspp{} warns if two variables have the
759 same variable label, since these categories cannot be distinguished in
760 output.
762 @item
763 @subcmd{COUNTEDVALUES} instead uses each variable's value label for the counted
764 value.  @pspp{} warns if two variables have the same value label for the
765 counted value or if one of the variables lacks a value label, since
766 such categories cannot be distinguished in output.
767 @end itemize
769 @item
770 @subcmd{LABEL} optionally specifies a label for the multiple response set.  If
771 neither @subcmd{LABEL} nor @subcmd{LABELSOURCE=VARLABEL} is specified, the set is
772 unlabeled.
774 @item
775 @subcmd{LABELSOURCE=VARLABEL} draws the multiple response set's label from the
776 first variable label among the variables in the set; if none of the
777 variables has a label, the name of the first variable is used.
778 @subcmd{LABELSOURCE=VARLABEL} must be used with @subcmd{CATEGORYLABELS=COUNTEDVALUES}.
779 It is mutually exclusive with @subcmd{LABEL}.
780 @end itemize
782 The @subcmd{MCGROUP} subcommand creates a new multiple category set or
783 replaces an existing multiple response set.  The @subcmd{NAME} and @subcmd{VARIABLES}
784 specifications are required, and @subcmd{LABEL} is optional.  Their meanings
785 are as described above in @subcmd{MDGROUP}.  @pspp{} warns if two variables in the
786 set have different value labels for a single value, since each of the
787 variables in the set should have the same possible categories.
789 The @subcmd{DELETE} subcommand deletes multiple response groups.  A list of
790 groups may be named within a set of required square brackets, or ALL
791 may be used to delete all groups.
793 The @subcmd{DISPLAY} subcommand displays information about defined multiple
794 response sets.  Its syntax is the same as the @subcmd{DELETE} subcommand.
796 Multiple response sets are saved to and read from system files by,
797 @i{e.g.}, the @cmd{SAVE} and @cmd{GET} command.  Otherwise, multiple
798 response sets are currently used only by third party software.
800 @node LEAVE
801 @section LEAVE
802 @vindex LEAVE
804 @cmd{LEAVE} prevents the specified variables from being
805 reinitialized whenever a new case is processed.
807 @display
808 LEAVE @var{var_list}.
809 @end display
811 Normally, when a data file is processed, every variable in the active
812 dataset is initialized to the system-missing value or spaces at the
813 beginning of processing for each case.  When a variable has been
814 specified on @cmd{LEAVE}, this is not the case.  Instead, that variable is
815 initialized to 0 (not system-missing) or spaces for the first case.
816 After that, it retains its value between cases.
818 This becomes useful for counters.  For instance, in the example below
819 the variable @code{SUM} maintains a running total of the values in the @code{ITEM}
820 variable.
822 @example
823 DATA LIST /ITEM 1-3.
824 COMPUTE SUM=SUM+ITEM.
825 PRINT /ITEM SUM.
826 LEAVE SUM
827 BEGIN DATA.
832 END DATA.
833 @end example
835 @noindent Partial output from this example:
837 @example
838 123   123.00
839 404   527.00
840 555  1082.00
841 999  2081.00
842 @end example
844 It is best to use @cmd{LEAVE} command immediately before invoking a
845 procedure command, because the left status of variables is reset by
846 certain transformations---for instance, @cmd{COMPUTE} and @cmd{IF}.
847 Left status is also reset by all procedure invocations.