SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating a Single Observation from Multiple Records
Combining Line Pointer Controls


The forward slash (/) line pointer control and the #n line pointer control may be used in combination within a SAS program to read multiple records in both sequential and nonsequential order.

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;

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 


  • 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 to read the values for Fname and Lname.

  • 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.

Note: You can also use just the #n line pointer control (as shown earlier in this lesson 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;
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 


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement