User Guide

305
Working with Co
mmand Syntax
Lag Functions
One notable exception is transformation commands that contain lag functions. In a
series of transformation commands without any intervening EXECUTE commands
or other com
mands that read the data, lag functions are calculated after all other
transformations, regardless of command order. For example:
COMPUTE lagvar=LAG(var1)
COMPUTE var1=var1*2
and
COMPUTE lagvar=LAG(var1)
EXECUTE
COMPUTE var1=var1*2
yield very different results for the value of lagvar, since the former uses the
transformed value of var1 while the latter uses the original value.