Help using Base SAS procedures

Operations calling values of a variable in specific rows ...

Reply
N/A
Posts: 0

Operations calling values of a variable in specific rows ...

Hi !
How could I perform operations with the value of a variable in a specific row ? could be the previous row (n-1.variable), the next one (n+1.variable), the first (first.variable), the last (last.variable) or the value from a variable in a specific row number (rowx.variable).


I am trying to perform operations like:


if n.variable ne n-1.variable then y=1;


Thanks in advance.

Asier
Valued Guide
Posts: 2,175

Re: Operations calling values of a variable in specific rows ...

have you looked at the LAG() function?
N/A
Posts: 0

Re: Operations calling values of a variable in specific rows ...

Thanks a lot Peter, the LAG() function solved my doubt.

Asier.
Ask a Question
Discussion stats
  • 2 replies
  • 106 views
  • 0 likes
  • 2 in conversation