Displaying 1 result from an estimated 1 matches for "bl14".
Did you mean:
b514
2007 Jun 04
1
Help with conditional lagging of data
...sure X. I need to create a column which gives me a lag for each ID (note not a continous lag), but a lag conditional on the id and the given year. Please find below a sample of the data
Input file sample
ID Year X
AB12 2000 100
AB12 2001 120
AB12 2002 140
AB12 2003 80
BL14 2000 180
BL14 2001 150
CR93 2000 45
CR93 2001 49
CR93 2002 56
CR93 2003 67
Expected output from this data
ID Year Xlag
AB12 2000 .
AB12 2001 20
AB12 2002 20
AB12 2003 -60
BL12 2000 .
BL14 2001 -30
CR93 2000 .
CR93 2001 5
C...