Reading Raw Data in Fixed Fields |
Using
Informats |
Data Step Processing of
Informats
Let's place our INPUT statement in the context of a DATA step and submit it for processing. Remember that, after the DATA step is submitted, it is compiled and then executed. |
data perm.empinfo; infile empdata; input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3. @19 Salary comma9.; run; |
During the compile phase, the character variables in the
program data vector are defined with the exact length specified by the informat.
But notice that the lengths defined for JobTitle and
Salary in the program data vector are different from the lengths
specified by their informats. |
123 123456789 | ||||
|
Remember, by default, SAS software stores numeric values
(no matter how many digits the value contains) as floating point numbers
in 8 bytes of storage. The length of a stored numeric variable is not affected
by an informat's width or other column specifications in an INPUT statement.
However, it is still necessary to specify the actual width of a raw data field in an INPUT statement. Otherwise, if you specify a default field width of 8 for all numeric values, you'll get inappropriate variable values when the program executes.
In the example below, the values for |
data perm.empinfo; infile empdata; input @9 FirstName $5. @1 LastName $7. +7 JobTitle 8. @19 Salary comma8.; run; |
12345678
12345678 |
||||
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.