Line-Hold Specifiers

SAS software provides two line-hold specifiers.

  • The trailing at sign (@) enables the next INPUT statement to read from the current record in the same iteration of the DATA step.

  • The double trailing at sign (@@) enables the next INPUT statement to read from the current record across further iterations of the DATA step.

The term trailing indicates that the @ or @@ must be the last item specified in the INPUT statement, as shown in this example:

     input name $20. @;     or     input name $20. @@;

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

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

Trailing At Sign (@)

Normally, each INPUT statement in a DATA step reads from a new record. But when you use the @, the following occurs:
  • the input pointer remains at the same line, rather than moving down to the next record.

data perm.dataset; 
   infile rawdata;
   input id 3. @;
   .
   .
   .
   input activity $;

1---V----10---+----20--
001 WALKING AEROBICS 
002 SWIMMING CYCLING
003 TENNIS SWIMMING 

 

  • the next INPUT statement (in the same iteration of the DATA step) continues reading the same record, rather than the new one.

data perm.dataset; 
   infile rawdata;
   input id 3. @;
   .
   .
   .
   input activity $;

1---+----10V--+----20--
001 WALKING AEROBICS 
002 SWIMMING CYCLING
003 TENNIS SWIMMING 

 

A record held by the trailing @ is automatically released when
  • a subsequent INPUT statement without a line-hold specifier executes.

data perm.dataset; 
   infile rawdata;
   input id 3. @;
   .
   .
   .
   input activity $;

V---+----10---+----20--
001 WALKING AEROBICS 
002 SWIMMING CYCLING 
003 TENNIS SWIMMING 

  • control returns to the top of the DATA step to begin the next iteration.

     data perm.dataset;
        infile rawdata;
        input id 3. @;  
         .
         .
         .
     run;

Double Trailing At Sign (@@)

Normally, each time a DATA step executes, the INPUT statement reads a new record. But when you use the @@, the INPUT statement holds the current record and reads the next value.

input score;    

1---+----10---+-
102 92 78 103 
84 23 36  75 

Program Data Vector

input score @@; 

1---+----10---+-
102 92 78 103 
84 23 36 75 

Program Data Vector

A record held by the double trailing at sign (@@) is not released until
  • the input pointer moves past the end of the record. Then the input pointer moves down to the next record

    1---+----10--V+-
    102 92 78 103 
    84 23 36 75



  • an INPUT statement without a line-hold specifier executes.
     input id 4. @@;    
     .                    
     .                    
     input department 5.;





Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement