1
votes

When reading an input file where one line contains more than one observation, we can use either '@' or '@@'.

When should we use one over the other?

1

1 Answers

4
votes

Use the double @ when you want the pointer to remain in the same place for the next iteration of the data step. If you just want the pointer to remain in place the next INPUT statement in the current iteration of the data step then you just need to use one trailing @.

Example reading one line with multiple iterations of the data step.

data want;
  id+1;
  input score @@;
cards;
10 20 30 45 
;

Example reading from one line multiple times in the same iteration of the data step.

data want;
  infile cards truncover ;
  input id score @;
  do rep=1 by 1 until (score=.);
    output;
    input score @;
  end;
cards;
1 10 20 30 45 
2 15 32
3 5 6 8 12 13 56
;