Arrays SAS:在列中的最后一个条目后添加值
我有以下数据集:Arrays SAS:在列中的最后一个条目后添加值,arrays,loops,sas,Arrays,Loops,Sas,我有以下数据集: Student TestDay Score 001 1 85 001 6 76 001 7 89 002 1 92 002 5 82 002 7 93 我想在“Score”列中最
Student TestDay Score
001 1 85
001 6 76
001 7 89
002 1 92
002 5 82
002 7 93
我想在“Score”列中最后一个非空值之后添加一个“100”值,并在TestDay的值中添加一个。因此,新数据如下所示:
Student TestDay Score
001 1 85
001 6 76
001 7 89
001 8 100
002 1 92
002 5 82
002 7 93
002 8 100
不需要数组或循环
data want;
set have;
by student;
output;
if last.student then do;
score=100;
testday=testday+1;
output;
end;
run;
如果最后一个值的分数已经为100,会发生什么情况?如果最后一天不是7点怎么办?如果最后一天已经8点了怎么办?