Reading Raw Data in Fixed Fields |
Using Formatted
Input |
Using the @n Column Pointer Control
The @n is an absolute pointer control that moves the input pointer to a specific column number. The @ moves the pointer to column n, which is the beginning column of the field being read. input @n variable informat.; |
Let's use the @n pointer control to locate variable
values in the external file Empdata. As you can see, the
values for LastName begin in column 1. We could start with the
@1 pointer control.
input @1 LastName $7. However, the default column pointer location is column 1, so a column pointer control is not required to read the first field. |
input LastName $7. |
EVANS DONNY 112 29,996.63
HELMS LISA 105 18,567.23
HIGGINS JOHN 111 25,309.00
LARSON AMY 113 32,696.78
MOORE MARY 112 28,945.89
POWELL JASON 103 35,099.50
RILEY JUDY 111 25,309.00
Next, the values for FirstName begin in column
9. To point to column 9, use an @ sign and the column number in the INPUT
statement: |
input LastName $7. @9 FirstName $5. |
EVANS DONNY 112 29,996.63
HELMS LISA 105 18,567.23
HIGGINS JOHN 111 25,309.00
LARSON AMY 113 32,696.78
MOORE MARY 112 28,945.89
POWELL JASON 103 35,099.50
RILEY JUDY 111 25,309.00
The $7. and $5. informats are explained later in this lesson. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.