Chapter Contents

Previous

Next
DIF

DIF



Returns differences between the argument and its nth lag

Category: Special


Syntax
Arguments
Details
Comparisons
Examples
See Also

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 nth lag. DIF1 can also be written as DIF. DIFn is defined as DIFN(x)=x-LAGN(x) .

For details on storing and returning values from the LAGn 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;
 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


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.