FIXED, FREE, and LIST Keywords (DATA LIST command)

FIXED, FREE, or LIST indicates the format of the data. Only one of these keywords can be used on each DATA LIST. The default is FIXED.

FIXED. Fixed-format data. Each variable is recorded in the same column location on the same record for each case in the data. FIXED is the default.

FREE. Freefield data. The variables are recorded in the same order for each case but not necessarily in the same column locations. More than one case can be entered on the same record. By default, values are separated by blanks or commas. You can also specify different value delimiters.

LIST. Freefield data with one case on each record. The variables are recorded in freefield format as described for the keyword FREE except that the variables for each case must be recorded on one record.

  • FIXED, FREE, or LIST must be separated from other DATA LIST subcommands by at least one blank or comma.
  • FIXED, FREE, or LIST must precede the first slash, which signals the beginning of data definition.
  • For fixed-format data, you can use column-style or FORTRAN-like formats, or a combination of both. For freefield data, you can use only FORTRAN-like formats.
  • For fixed-format data, the program reads values according to the column locations specified or implied by the FORTRAN-like format. Values in the data do not have to be in the same order as the variables named on DATA LIST and do not have to be separated by a space or column.
  • See String Formats (DATA LIST command) for information on column width specifications for string variables in UTF-8 format data files.
  • For freefield data, the program reads values sequentially in the order in which the variables are named on DATA LIST. Values in the data must be in the order in which the variables are named on DATA LIST and must be separated by at least one valid delimiter.
  • For freefield data, multiple blank spaces can be used to indicate missing information only if a blank space is explicitly specified as the delimiter. In general, it is better to use multiple nonblank delimiters (for example, two commas with no intervening space) to specify missing data.
  • In freefield format, a value cannot be split across records.

Example

* Data in fixed format.
 
DATA LIST FILE="/data/hubdata.txt" FIXED RECORDS=3
  /1 YRHIRED 14-15 DEPT 19 SEX 20.
  • FIXED indicates explicitly that the hubdata.txt file is in fixed format. Because FIXED is the default, the keyword FIXED could have been omitted.
  • Variable definition begins after the slash. Column locations are specified after each variable. Since formats are not specified, the default numeric format is used. Variable widths are determined by the column specifications: YRHIRED is two digits wide, and DEPT and SEX are each one digit wide.

Example

* Data in freefield format. 

DATA LIST FREE / POSTPOS NWINS.
BEGIN DATA
2, 19, 7, 5, 10, 25, 5, 17, 8, 11, 3,, 6, 8, 1, 29
END DATA.
  • Data are inline, so FILE is omitted. The keyword FREE is used because data are in freefield format with multiple cases on a single record. Two variables, POSTPOS and NWINS, are defined. Since formats are not specified, both variables receive the default F8.2 format.
  • All of the data are recorded on one record. The first two values build the first case in the active dataset. For the first case, POSTPOS has value 2 and NWINS has value 19. For the second case, POSTPOS has value 7 and NWINS has value 5, and so on. The active dataset will contain eight cases.
  • The two commas without intervening space after the data value 3 indicate a missing data value.

Example

* Data in list format.
 
DATA LIST LIST (",")/ POSTPOS NWINS.
BEGIN DATA
2,19
7,5
10,25
5,17
8,11
3, 
6,8
1,29
END DATA.
  • This example defines the same data as the previous example, but LIST is used because each case is recorded on a separate record. FREE could also be used. However, LIST is less prone to errors in data entry. If you leave out a value in the data with FREE format, all values after the missing value are assigned to the wrong variable. Since LIST format reads a case from each record, a missing value will affect only one case.
  • A comma is specified as the delimiter between values.
  • Since line endings are interpreted as delimiters between values, the second comma after the value 3 (in the sixth line of data) is not necessary to indicate that the value of NWINS is missing for that case.