Creating a Single Observation from Multiple Records | |
Reading Multiple Records in Any
Order |
Execution of the DATA Step
The #n pointer controls in the program below cause four records to be read for each execution of the DATA step. data perm.patients; infile patdata; input #4 ID $5. #1 Fname $ Lname $ #2 Address $23. #3 City $ State $ Zip $ #4 @7 Doctor $6.; run; |
The first time that the DATA step executes, the first four records are read, and an observation is written to the data set. |
1---+----10---+----20--- |
ALEX BEDWAN |
609 WILTON MEADOW DRIVE |
GARNER NC 27529 |
XM034 FLOYD |
ALISON BEYER |
8521 HOLLY SPRINGS ROAD |
APEX NC 27502 |
XF124 LAWSON |
During the second iteration, the next four records are read, and the second observation is written to the data set. |
1---+----10---+----20--- |
ALEX BEDWAN |
609 WILTON MEADOW DRIVE |
GARNER NC 27529 |
XM034 FLOYD |
ALISON BEYER |
8521 HOLLY SPRINGS ROAD |
APEX NC 27502 |
XF124 LAWSON |
PROC PRINT output of the data set illustrates how information spread
over several records is condensed into one observation.
proc print data=perm.patients noobs; run; |
ID | Fname | Lname | Address | City | State | Zip | Doctor |
XM034 |
ALEX | BEDWAN | GARNER | NC | 27529 | FLOYD | |
XF124 |
ALISON | BEYER | 8521 HOLLY SPRINGS ROAD | APEX | NC | 27502 | LAWSON |
XF232 |
LISA | BONNER | 109 BRAMPTON AVENUE | CARY | NC | 27511 | LAWSON |
XM065 |
GEORGE | CHESSON | 3801 WOODSIDE COURT | GARNER | NC | 27529 | FLOYD |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.