SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating a Single Observation from Multiple Records
Reading Multiple Records in Sequential Order


Using The / Line Pointer Control

Take a closer look at using the forward slash (/) line pointer control in the following example.

The raw data file Memdata contains the mailing list of a professional organization. Your task is to combine the information for each member into one data set observation. We'll begin by reading each member's name, followed by the street address, and finally the city, state, and zip code.

  • As you write the instructions to read the values for Fname and Lname, notice that all the values for Lname do not begin in the same column. So, you should use list input to read these values.


     data perm.members;   
        infile memdata;
        input Fname $ Lname $
1---+----10---+----20
LEE ATHNOS  
1215 RAINTREE CIRCLE 
PHOENIX  AZ 85044  
HEIDIE BAKER  
1751 DIEHL ROAD  
VIENNA  VA 22124  
MYRON BARKER 
131 DONERAIL DRIVE 
ATLANTA  GA 30363 
JOYCE BENEFIT 
85 MAPLE AVENUE 
MENLO PARK  CA 94025 


  • Now you want to read the values for Address from the second record. The / line pointer control advances the input pointer to the next record. At this point the INPUT statement is incomplete, so a semicolon should not be placed after the line pointer control.


     data perm.members;
        infile memdata;
        input Fname $ Lname $ /

1---+----10---+----20
LEE ATHNOS  
1215 RAINTREE CIRCLE 
PHOENIX  AZ 85044  
HEIDIE BAKER  
1751 DIEHL ROAD  
VIENNA  VA 22124  
MYRON BARKER 
131 DONERAIL DRIVE 
ATLANTA  GA 30363 
JOYCE BENEFIT 
85 MAPLE AVENUE 
MENLO PARK  CA 94025 


  • You can use column input to read the values in the next record as one variable named Address. Then add a line pointer control to move the input pointer to the next record.


     data perm.members;
        infile memdata;
        input Fname $ Lname $ /
              Address $ 1-20 /
1---+----10---+----20
LEE ATHNOS  
1215 RAINTREE CIRCLE 
PHOENIX  AZ 85044  
HEIDIE BAKER  
1751 DIEHL ROAD  
VIENNA  VA 22124  
MYRON BARKER 
131 DONERAIL DRIVE 
ATLANTA  GA 30363 
JOYCE BENEFIT 
85 MAPLE AVENUE 
MENLO PARK  CA 94025 


  • As you write the statements to read the values for City, notice that some of the values are longer than eight characters and contain embedded blanks. Also note that each value is followed by two consecutive blanks. So, modified list input, with the ampersand modifier (&),  is appropriate here.

    The values for State and the values for Zip do not begin in the same column. Therefore, you should use list input to read these values.


     data perm.members; 
        infile memdata;
        input Fname $ Lname $ /
              Address $ 1-20 /
              City & $10. State $ Zip $;
     run;
1---+----10---+----20
LEE ATHNOS  
1215 RAINTREE CIRCLE 
PHOENIX  AZ 85044  
HEIDIE BAKER  
1751 DIEHL ROAD  
VIENNA  VA 22124  
MYRON BARKER 
131 DONERAIL DRIVE 
ATLANTA  GA 30363 
JOYCE BENEFIT 
85 MAPLE AVENUE 
MENLO PARK  CA 94025 



back||next


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

Terms of Use & Legal Information | Privacy Statement