DIF Function


Returns differences between the argument and its n th lag

Category: Special

Syntax

DIF < n >( argument )

Arguments

n

  • specifies the number of lags.

argument

  • is numeric.

Details

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.

Comparisons

The function DIF2(X) is not equivalent to the second difference DIF(DIF(X)).

Examples

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 

See Also

Function:

  • 'LAG Function' on page 621




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net