LAG, ZLAG, XLAG, SLAG or CLAG Statement |
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.