从SAS中的一行读取多个观测值

从SAS中的一行读取多个观测值,sas,Sas,当读取一行包含多个观测值的输入文件时,我们可以使用“@”或“@” 什么时候我们应该使用一个而不是另一个?当您希望指针在数据步骤的下一次迭代中保持在同一位置时,请使用双精度@。如果您只希望指针在数据步骤的当前迭代中的下一个输入语句中保持原位,那么只需要使用一个尾随@ 示例读取数据步骤多次迭代的一行 data want; id+1; input score @@; cards; 10 20 30 45 ; data want; infile cards truncover ; i

当读取一行包含多个观测值的输入文件时,我们可以使用“@”或“@”


什么时候我们应该使用一个而不是另一个?

当您希望指针在数据步骤的下一次迭代中保持在同一位置时,请使用双精度@。如果您只希望指针在数据步骤的当前迭代中的下一个输入语句中保持原位,那么只需要使用一个尾随@

示例读取数据步骤多次迭代的一行

data want;
  id+1;
  input score @@;
cards;
10 20 30 45 
;
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
;
在数据步骤的同一迭代中多次从一行读取示例

data want;
  id+1;
  input score @@;
cards;
10 20 30 45 
;
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
;

如果希望指针在数据步骤的下一次迭代中保持在同一位置,请使用双精度@。如果您只希望指针在数据步骤的当前迭代中的下一个输入语句中保持原位,那么只需要使用一个尾随@

示例读取数据步骤多次迭代的一行

data want;
  id+1;
  input score @@;
cards;
10 20 30 45 
;
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
;
在数据步骤的同一迭代中多次从一行读取示例

data want;
  id+1;
  input score @@;
cards;
10 20 30 45 
;
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
;