LAG function

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.

LAG Function (SAS 9.2 Doc)

*** Use a third variable to assign the value from the previous record;

array one a b c d;
array two e f g h;
&nbsp &nbsp &nbsp do over one;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp temp = lag(one);
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if first.id = 0 and last.id=1 and two = . then do;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp two = temp;
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp end;
&nbsp &nbsp &nbsp end;

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.