statsguyz
statsguyz

Reputation: 469

SAS: Adding value after last entry in column

I have the following data set:

Student     TestDay          Score
001         1                85
001         6                76
001         7                89
002         1                92
002         5                82
002         7                93

I'd like to add a '100' value after the last non-empty value in the column 'Score', as well as add one to the value of TestDay. So the new data would look like the following:

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

Upvotes: 0

Views: 42

Answers (1)

Tom
Tom

Reputation: 51591

No need for arrays or loops.

data want;
  set have;
  by student;
  output;
  if last.student then do;
    score=100;
    testday=testday+1;
    output;
  end;
run;

Upvotes: 1

Related Questions