reading next observation's value in current observation

后端 未结 3 1172
梦如初夏
梦如初夏 2020-12-08 12:26

I\'ve a dataset called \'input\' with the following observations

ID Salary
10 1000
20 2000
30 3000
40 4000

I need an output dataset with

3条回答
  •  甜味超标
    2020-12-08 12:48

    There are a few ways to achieve this, here's how I would do it.

    data have;
       input ID Salary;
       cards;
    10 1000
    20 2000
    30 3000
    40 4000
    ;
    run;
    
    data want;
       recno=_n_+1;
       set have end=last;
       if not last 
               then set have (keep=salary rename=(salary=next_row_salary)) point=recno;
          else call missing(next_row_salary);
    run;
    

提交回复
热议问题