The PANEL Procedure |
LAG, ZLAG, XLAG, SLAG or CLAG Statement |
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:
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.
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.
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.
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.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.