Previous Page | Next Page

The PANEL Procedure

LAG, ZLAG, XLAG, SLAG or CLAG Statement
LAG var( ... ) , ..., var( ... ) < / OUT= SAS-data-set > ;
Generally, creating lags of variables in a panel setting is a tedious process in which you must generate many DATA STEP statements. The PANEL procedure now enables you to generate lags of any series without jumping across any individual’s boundary. The lag statement is a data set generation tool. Using the data created by a LAG statement requires a subsequent PROC PANEL call. There can be more than one LAG statement in each call to PROC PANEL.
The LAG statement tends to generate many missing values in the data. This can be problematic, because the number of usable observations diminishes with the lag length. Therefore, PROC PANEL offers alternatives to the LAG statement. The OUT= option must be specified on the LAG statement. The output data set includes all variables in the input set, plus the lags that are denoted with the convention originalvar_lag. The following statements can be used instead of LAG with otherwise identical syntax:
CLAG

replaces missing values with the cross section mean for that variable in that cross section. Note that missing values are replaced only if they are in the generated (lagged) series. Missing variables in the original variables are not changed.

SLAG

replaces missing values with the time mean for that variable in that time period. Note that missing values are replaced only if they are in the generated (lagged) series. Missing variables in the original variables are not changed.

XLAG

replaces missing values with the overall mean for that variable. Note that missing values are replaced only if they are in the generated (lagged) series. Missing variables in the original variables are not changed.

ZLAG

replaces missing values with zero for that variable. Note that missing values are replaced only if they are in the generated (lagged) series. Missing variables in the original variables are not changed.

Assume that data set A has been sorted by cross section and time period within cross section (or FLATDATA has been specified), and the variables are Y, X1, X2 and X3. You desire the lags 1 and 3 of the X1 variable; lag 3, 6, and 9 of X2; and lag 2 of variable X3. The following PROC PANEL statements generate a series with those characteristics.

   proc panel data=A;
      id i t;
      lag X1(1 3) X2(3 6 9) X3(2) / out=A_lag;
   run;

If you want a zeroing instead of missing values, then you specify the following:

   proc panel data=A;
      id i t;
      zlag X1(1 3) X2(3 6 9) X3(2) / out=A_zlag;
   run;

Similarly, you can specify XLAG to replace with overall means, SLAG to replace with time means, and CLAG to replace with cross section means.

Previous Page | Next Page | Top of Page