Last active
August 29, 2015 14:10
-
-
Save joosti/83336b3690e9a53f98c9 to your computer and use it in GitHub Desktop.
SAS data step, lag example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data dataOut; | |
set dataIn; | |
by gvkey fyear; | |
sale_lag1 = ifn(gvkey=lag(gvkey) and fyear=lag(fyear)+1, lag(sale), .); | |
sale_lag2 = ifn(gvkey=lag2(gvkey) and fyear=lag2(fyear)+2, lag2(sale), .); | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment