SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating a Single Observation from Multiple Records
Lesson Summary


This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.

Multiple Records per Observation
Information for one observation can be spread out over several records. You can write one INPUT statement that contains a line pointer control to specify the record(s) from which values are read.

Line Pointer Controls
In addition to column pointer controls, SAS software provides line pointer controls to direct the input pointer to a specific line or record.

Reading Multiple Records in Sequential Order
The forward slash (/) line pointer control is used to read multiple records in sequential order. Each time a / pointer is encountered, the input pointer advances to the next line.

Reading Multiple Records in Any Order
The #n line pointer control is used to read multiple records in any order. The #n specifies the absolute number of the line to which you want to move the pointer.

Combining Line Pointer Controls
The / line pointer control and the #n line pointer control may be combined within a SAS program to read multiple records in both sequential and nonsequential order.


II. Syntax

To go to the page where a statement or option was presented, select a link.

LIBNAME libref  'SAS-data-library';
FILENAME fileref 'filename';
DATA SAS-data-set;
        INFILE raw-data-file;
        INPUT #n variable . . .
                    #n @n variable . . . /
                    variable . . . /
                    variable . . . ;
RUN;
PROC PRINT DATA=SAS-data-set
RUN;


III. Sample Program
     libname perm 'c:\records\empdata';
     filename personel 'c:\records\empdata\new.dat';
     data perm.emplist3;
        infile personel;
        input #2 Department $ 5-16
              #1 @16 ID $4. @1 Name $14. /
                 JobCode 3. /
                 Salary comma9.;
     run;
     proc print data=perm.emplist3;
     run;


IV. Points to Remember
  • When files contain multiple records per observation, there must be the same number of records for each observation being created.

  • Because the / pointer control can only advance forward, the pointer control is specified after the values in the current record are read.

  • The #n pointer control can read records in any order and must be specified before the variables' names are defined.

  • A semicolon should be placed at the end of the complete INPUT statement.


back||next

 

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

Terms of Use & Legal Information | Privacy Statement