Returns differences between the argument and its n th lag
Category: Special
DIF < n >( argument )
n
specifies the number of lags.
argument
is numeric.
The DIF functions, DIF1, DIF2, ..., DIF100, return the first differences between the argument and its n th lag. DIF1 can also be written as DIF. DIF n is defined as DIF n ( x )= x -LAG n ( x ).
For details on storing and returning values from the LAG n queue, see the LAG function.
The function DIF2(X) is not equivalent to the second difference DIF(DIF(X)).
This example demonstrates the difference between the LAG and DIF functions.
data two; input X @@; Z=lag(x); D=dif(x); datalines; 1 2 6 4 7 ; proc print data=two; run;
Results of the PROC PRINT step follow:
OBS X Z D 1 1 . . 2 2 1 1 3 6 2 4 4 4 6 2 5 7 4 3
Function:
'LAG Function' on page 621