Reading Variable-Length Records |
Reading Records with a Varying Number of
Fields |
Now, let's think about another type of variable-length record, one whose length varies due to the number of fields it contains rather than the field length. |
The file referenced by the fileref Bpdata contains variable-length records in which an employee ID number is followed by repeating blocks of data that represent dates and blood pressure readings. Notice that each repeating block of data in the file is the same length. However, each record contains a varying number of repeating blocks. |
1---+----10---+----20---+----30---+----40---+----50 |
1234 13MAR89 120/80 |
1443 12FEB89 120/70 03FEB90 125/80 07OCT90 125/99 |
1681 11JAN90 120/80 05JUN90 110/70 |
2034 19NOV88 130/70 12MAY89 150/90 23MAR90 130/80 |
You can read this file and create one observation for each block of data. |
Obs | ID | Date | BP |
1 | 1234 | 13MAR89 | 120/80 |
2 | 1443 | 12FEB89 | 120/70 |
3 | 1443 | 03FEB90 | 125/80 |
4 | 1443 | 07OCT90 | 125/99 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.