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
There's no direct way to do this in a data step. There's two approaches you can use:
Option 1: Sort in reverse, use the lag function
proc sort data=your_dataset;
by descending id;
run;
data your_dataset;
set your_dataset;
next_row_salary = lag(salary);
run;
proc sort; by id; run;
Options 2: Use proc expand
proc expand data=your_dataset method=none;
by id;
convert salary = next_row_salary / transformout=(lead 1);
run;