The forward slash (/) line pointer
control and the #n line pointer
control can be used together in a SAS program to read multiple records
both sequentially and non-sequentially.
For example, you could
use both the / line pointer control and the #n line
pointer control to read the variables in the raw data file Patdata
in the following order:
1. ID
2. Fname
3. Lname
4. Address
|
5. City
6. State
7. Zip
8. Doctor
|
data perm.patients;
infile patdata;
input #4 ID $5.
#1 Fname $ Lname $ /
Address $23. /
City $ State $ Zip $ /
@7 Doctor $6.;
run;
-
To read the values for ID in the
fourth record, specify #4 before naming the variable and defining
its attributes.
-
Specify #1 to move the input pointer
back to the first record, where the values for Fname and Lname are
read.
-
Because the next record to be read
is sequential, you can use the / line pointer control after the variable
Lname to move the input pointer to the second record, where the value
for Address is read.
-
The / line pointer control in the
next line directs the input pointer to the third record, where the
values for City, State, and Zip are read.
-
The final / line pointer control
moves the input pointer back to the fourth record, where the value
for Doctor is read.
Tip
Alternatively, you can use
just the #
n line pointer control
(as shown earlier in this chapter and below) to read the variables
in the order shown above.
data perm.patients;
infile patdata;
input #4 ID $5.
#1 Fname $ Lname $
#2 Address $23.
#3 City $ State $ Zip $
#4 @7 Doctor $6.;
run;