Reading Variable-Length Records |
Reading Records with a Varying Number of
Fields |
Now let's think about how to read the repeating blocks of data in each record. You can see that each block of data is the same length, 14 columns. Add one more column, to include the blank that delimits each block, and the total length of each block is 15 columns. |
15
15
15 | 14 | | 14 | | 14 | |
|||||
|
So, you need to execute statements that read each block of 15 columns and output the values as an observation until the end of the record is reached. You can repeatedly execute these statements in an iterative DO loop. |
data perm.health; infile bpdata length=reclen; input ID 4. @; do index=6 to reclen by 15; |
The index variable determines how many times the loop will
execute. Now you need to think about what kinds of statements need to be
executed within the loop.
|
data perm.health; infile bpdata length=reclen; input ID 4. @; do index=6 to reclen by 15; input Date : date. BP $ @; output; end; run; |
The RUN statement completes the DATA step. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.