SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Multiple Observations from a Single Record
Reading the Same Number of Repeating Fields


In this example, the first INPUT statement reads the values for ID and uses the @ to hold the current record for the next INPUT statement in the DATA step.

     data perm.sales97;
        infile data97;
        input ID $4. @;
        .
        .
        .
        input Sales : comma. @;

Raw Data File Data97
1---V----10---+----20---+----30---+----40
0734 1,323.34 2,472.85 3,276.65 5,345.52
0943 1,908.34 2,560.38 3,472.09 5,290.86
1009 2,934.12 3,308.41 4,176.18 7,581.81


The second INPUT statement reads a value for Sales and holds the record. The COMMAw.d informat in the INPUT statement reads the numeric values for Sales and removes the embedded commas.  

Note: Notice that the COMMAw.d informat does not specify a w value. Remember that list input reads values until the next blank is detected. The default length of numeric variables is 8 bytes, so you don't need to specify a w value to determine the length of a numeric variable.

When all of the repeating fields have been read, control returns to the top of the DATA step, and the record is released.

     Data perm.sales97;
        infile data97;
        input ID 4. @;
        .
        .
        .
        input Sales : comma. @;

Raw Data File Data97
1---+----10--V+----20---+----30---+----40
0734 1,323.34 2,472.85 3,276.65 5,345.52
0943 1,908.34 2,560.38 3,472.09 5,290.86
1009 2,934.12 3,308.41 4,176.18 7,581.81



back||next


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

Terms of Use & Legal Information | Privacy Statement