I have the following dataset:

```
AGE    HSQ    PCT

65      1     0.7
65      2     0.2
65      3     0.1
66      1     0.5
66      2     0.25
66      3     0.25

[...]

```

What I need is to get the followig output:

```
AGE     P1    P2     P3

65     0.7    0.2    0.1
66     0.5    0.25   0.25

[...]

```

I have been told to adopt `LAG` and `FIRST.AGE` or `LAST.AGE` in order to do that, and to me it seems a good strategy. However I am not able to get the final result.. the (wrong) code I am using is:

```
DATA OUTPUT;
  SET SAMPLE;
    BY AGE HSQ;
  IF LAST.AGE THEN DO;
    P1=LAG2(PCT);
    P2=LAG1(PCT);
    P3=PCT;
  END;
RUN;

```

But it jumps to previus ages percentages, which is not what I need.. where is the syntax error? Thanks!