SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

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


Using the Single Trailing At Sign (@) to Hold the Current Record

First, you need to read the value for ID and hold the record so that subsequent values for Sales can be read.

     data perm.sales97;
        infile data97;
        input ID $4.

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


You are already familiar with the @@, which holds the current record across iterations of the DATA step.

However, in this case, you want to hold the record with the @ line hold specifier, so that a second INPUT statement can read the values for Sales within the same iteration of the DATA step. Like the @@, the single trailing @

  • enables the next INPUT statement to read from the same record
  • releases the current record when a subsequent INPUT statement executes without a line-hold specifier.

NOTE: Unlike the @@, the single @ also releases a record when control returns to the top of the DATA step for the next iteration.


It's easy to distinguish between the @@ and the @ by remembering that the

  • double trailing @ (@@) holds a record across iterations of the DATA step until the end of the record is reached.
  • single trailing @ releases a record when control returns to the top of the DATA step.


back||next


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

Terms of Use & Legal Information | Privacy Statement