Code:

```
data test;
input x y;
datalines;
1 2
1 4
5 7
;
data new;
set test;
diff = y - x;
lg = lag(y);
if x < lg then x = lg + 1;
* update x and y to be shifted;
y = x + diff;
run;
```

Code:

```
Obs x y diff lg
1 1 2 1 .
2 3 6 3 2
3 5 7 2 4
```

Code:

```
Obs x y diff lg
1 1 2 1 .
2 3 6 3 2
3 7 9 2 6
```