INPUT
<variables> <informats> <record-directives> <positionals> ;
The INPUT statement reads records from the current input file, placing the values into matrices. The INFILE statement sets up the current input file. See Chapter 8 for details.
The INPUT statement supports the following arguments:
specify the variable or variables you want to read from the current position in the record. Each variable can be followed immediately by an input format specification.
specify an input format. These are of the form or for standard numeric and character informats, respectively, where is the width of the field and is the decimal parameter, if any. You can also use a named SAS format such as BESTw.d. Also, you can use a single $ or & for list input applications. If the width is unspecified, the informat uses list-input rules to determine the length by searching for a blank (or comma) delimiter. The special format $RECORD. is used for reading the rest of the record into one variable. For more information about formats, see SAS Language Reference: Dictionary.
Record holding is always implied for RECFM=N binary files, as if the INPUT statement has a trailing @ sign. For more information, see Chapter 8.
Examples of valid INPUT statements follow:
input x y; input @1 name $ @20 sex $ @(20+2) age 3.; eight=8; input >9 <eight number2 ib8.;
The following example uses binary input:
file "out2.dat" recfm=n ; number=499; at=1; do i = 1 to 5; number=number+1; put >at number ib8.; at=at+8; end; closefile "out2.dat"; infile "out2.dat" recfm=n; size=8; /* 8 bytes */ do pos=1 to 33 by size; input >pos number ib8.; print number; end;
are used to advance to a new record. Record-directives are the following:
is used at the end of an INPUT statement to hold the current record so that you can continue to read from the record with later INPUT statements. Otherwise, the next record is used for the next INPUT statement.
advances to the next record.
specifies that the next record to be read start at the indicated byte position in the file (for RECFM= N files only). The operand is a literal number, a variable name, or an expression in parentheses.
specifies that the indicated number of bytes are read as the next record. The record directive must be specified for binary files (RECFM=N). The operand is a literal number, a variable name, or an expression in parentheses.
specifies a specific column on the record. The positionals are the following:
specifies a column, where operand is a literal number, a variable name, or an expression in parentheses. For example, @30 means to go to column 30. The operand can also be a character operand when pattern searching is needed. For more information, see Chapter 8.
skips the indicated number of columns. The operand is a literal number, a variable name, or an expression in parentheses.