Hello all,
I want to create a variable that will take the average of the 3 most recent observations of dayslate per id. Net_due_date should be used to determine which is the most recent observation. I do not need this to be a rolling average.
Has anyone got any ideas how to go about this?
Thanks in advance!
Kayleigh
I want to create a variable that will take the average of the 3 most recent observations of dayslate per id. Net_due_date should be used to determine which is the most recent observation. I do not need this to be a rolling average.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int(id Net_due_date dayslate) 2 22309 21 6 20095 9 37 20368 68 73 17480 -10 85 21253 -15 85 21839 4 89 21376 15 117 21852 -12 122 18005 13 139 18747 -22 197 22521 3 202 17985 -17 202 18165 -14 202 20498 -20 202 20895 -19 202 21075 -28 202 21426 -30 202 22264 -26 203 21001 -3 209 22028 12 215 17784 27 230 20875 -4 230 21334 -30 230 22614 -27 233 22195 19 239 21653 10 242 18090 9 243 21014 14 251 18076 -2 256 22297 42 256 21422 -27 256 17962 -30 256 20577 -21 256 18838 -1 256 21122 10 256 20930 -365 256 20849 -1 256 21050 16 293 17985 124 293 19021 -9 end format %td Net_due_date
Thanks in advance!
Kayleigh
Comment