Fixed-Format Data (DATA LIST command)

  • If column-style formats are used, you must specify the column location of each variable after the variable name. If the variable is one column wide, specify the column number. Otherwise, specify the first column number followed by a dash (–) and the last column number.
  • If several adjacent variables on the same record have the same width and format type, you can use one column specification after the last variable name. Specify the beginning column location of the first variable, a dash, and the ending column location of the last variable. The program divides the total number of columns specified equally among the variables. If the number of columns does not divide equally, an error message is issued.
  • The same column locations can be used to define multiple variables.
  • For FORTRAN-like formats, column locations are implied by the width specified on the formats. See the topic Variable Formats (DATA LIST command) for more information. To skip columns, use the Tn or nX format specifications.
  • With fixed format, column-style and FORTRAN-like specifications can be mixed on the same DATA LIST command.
  • Record location is indicated by a slash or a slash and record number before the names of the variables on that record. See the topic RECORDS Subcommand (DATA LIST command) for more information.
  • The program ignores data in columns and on records that are not specified on DATA LIST.
  • In the data, values do not have to be separated by a space or comma.
  • See String Formats (DATA LIST command) for information on column width specifications for string variables in UTF-8 format data files.

Example

DATA LIST  FILE="/data/hubdata.txt" RECORDS=3
  /1 YRHIRED 14-15 DEPT 19 SEX 20
  /2 SALARY 21-25.
  • The data are in fixed format (the default) and are read from the file HUBDATA.
  • Three variables, YRHIRED, DEPT, and SEX, are defined on the first record of the HUBDATA file. One variable, SALARY, is read from columns 21 through 25 on the second record. The total number of records per case is specified as 3 even though no variables are defined on the third record. The third record is simply skipped in data definition.

Example

DATA LIST  FILE="/data/hubdata.txt" RECORDS=3
  /1 DEPT 19 SEX 20 YRHIRED 14-15 MOHIRED 12-13 HIRED 12-15
  /2 SALARY 21-25.
  • The first two defined variables are DEPT and SEX, located in columns 19 and 20 on record 1. The next three variables, YRHIRED, MOHIRED, and HIRED, are also located on the first record.
  • YRHIRED is read from columns 14 and 15, MOHIRED from columns 12 and 13, and HIRED from columns 12 through 15. The variable HIRED is a four-column variable with the first two columns representing the month when an employee was hired (the same as MOHIRED) and the last two columns representing the year of employment (the same as YRHIRED).
  • The order of the variables in the dictionary is the order in which they are defined on DATA LIST, not their sequence in the HUBDATA file.

Example

DATA LIST  FILE="/data/hubdata.txt" RECORDS=3
  /1 DEPT 19 SEX 20 MOHIRED YRHIRED 12-15
  /2 SALARY 21-25.
  • A single column specification follows MOHIRED and YRHIRED. DATA LIST divides the total number of columns specified equally between the two variables. Thus, each variable has a width of two columns.

Example

* Mixing column-style and FORTRAN-like format specifications.

DATA LIST FILE=PRSNL / LNAME M_INIT STREET (A20,A1,1X,A10) 
    AGE 35-36.
  • FORTRAN-like format specifications are used for string variables LNAME, M_INIT, and STREET. These variables must be adjacent in the data file. LNAME is 20 bytes wide and is located in columns 1–20. M_INIT is one byte wide and is located in column 21. The 1X specification defines a blank column between M_INIT and STREET. STREET is 10 bytes wide and is located in columns 23–32.
  • A column-style format is used for the variable AGE. AGE begins in column 35, ends in column 36, and by default has numeric format.