Data editing > Writing out data > Writing to a report file > Data variables
 
Data variables
Quick reference
To print the contents of a data variable, type:
var_name
or
var_name(start,end)
To print the contents of a field, evaluated as an integer right-justified in a field of a given width, type:
var_name:field_width
To print a the contents of every column in a field, even if they are multicoded or blank, type:
start:field_width
start is the first position in the field. You can also use this notation to print fields whose contents evaluate to a value greater than the maximum integer value Quantum can deal with.
To print the contents of a data variable, type the variable’s name.
More information
All data variables that are single coded are printed using as many positions as there are columns in the variable. For example, if the data is:
----+----4
511 538253
  2
  &
the statement:
report rfile c31,c35,c40
prints the contents of columns 31, 35 and 40 one after the other, as follows:
553
The statement:
report rfile c(35,40)
prints the contents of columns 35 to 40:
538253
In both the examples the last column of the field has contained a code. If the last column or columns of a field are blank, Quantum omits those columns when printing the contents of the field. You can get round this by entering the field specification as start:field_width.
A single data variable that is blank is printed as such, while a single data variable that is multicoded is printed as an asterisk. The statement:
report rfile c35, c34, c33, c32
creates the line:
5 *1
If a variable refers to a string that contains multicoded or blank columns, Quantum ignores the multicodes and blanks and evaluates the contents of the remaining columns as an integer. For example, using the data shown above, the statement:
report rfile c(31,40)
prints a line containing the value 51538253. The value starts in the first print position available.
Note If the field you want to print is very long, its contents may produce an incorrect value when evaluated as an integer (the maximum integer value which Quantum can deal with is 1,073,741,824). You can get round this by specifying the first column and the field width as described below.
If you want to see all columns in a field which contains blanks or multicodes, or you need to have the correct evaluation of a long field, you must deal with each column in the field separately. You can type each column number separately, but it is quicker to specify the start column and the total number of columns you want to print starting at that column.
The format for this type of reference is:
start:field_width
For example, to print columns 31 to 40, type:
report rfil c31:10
The output from this command would be 51* 538253, the same as if you had typed each column number separately. As before, the data is printed starting in the first print position available.
You can use this alternative notation with field specifications too. In this instance Quantum evaluates the contents of the field as an integer and prints the result right-justified in a field of the given width. If you type, for example:
report rfil c(31,40):10
Quantum prints the value 51538253 in positions 3 to 10 of a ten-position field. The first two positions will be blank.
This notation is also useful if you need to create data files with fixed length records, and some records end with blank columns. Writing records to a data file preserves multicodes but ignores trailing blank columns. Writing to a report file allows you to create a single-coded data file with fixed length records. If your data is multicoded you must to convert it to single-coded form before writing it out. You can do this by ‘exploding’ any multicodes into a field of single codes: see Converting multicoded data to single-coded data.
When the data is in single-coded form, you can then write the whole record out to a report file using a reportn statement as follows:
reportn repdata c101:80
reportn repdata c201:80
See also
Writing to a report file