From the appended data example, I want to calculate momentum of stocks as the 11-month return of the stock during the period beginning 12 months prior to and ending one month prior to the measurement date. By this definition, momentum of stock i measured at the end of month t, which is denoted as Momi,t, is therefore taken to be the return of the stock during the 11-month period covering month t-11 through t-1.
The stock_id is the unique firm id, mdate represents monthly date and pr is the closing price of the stock observed at the end of given month.
Kindly suggest a code that measures the given momentum variable Momi,t,in this case.
The stock_id is the unique firm id, mdate represents monthly date and pr is the closing price of the stock observed at the end of given month.
Kindly suggest a code that measures the given momentum variable Momi,t,in this case.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int stock_id str56 stock float(mdate pr) 1 "3M India Ltd." 484 500 1 "3M India Ltd." 485 620.05 1 "3M India Ltd." 486 664 1 "3M India Ltd." 487 639.4 1 "3M India Ltd." 488 602 1 "3M India Ltd." 489 525.2 1 "3M India Ltd." 490 602.15 1 "3M India Ltd." 491 659.9 1 "3M India Ltd." 492 627 1 "3M India Ltd." 493 610 1 "3M India Ltd." 494 438.8 1 "3M India Ltd." 495 424.5 1 "3M India Ltd." 496 424.9 1 "3M India Ltd." 497 380.1 1 "3M India Ltd." 498 325.1 1 "3M India Ltd." 499 323 1 "3M India Ltd." 500 266 1 "3M India Ltd." 501 270 1 "3M India Ltd." 502 293 1 "3M India Ltd." 503 267 1 "3M India Ltd." 504 259.95 1 "3M India Ltd." 505 271 1 "3M India Ltd." 506 311.45 1 "3M India Ltd." 507 314.25 1 "3M India Ltd." 508 282.7 1 "3M India Ltd." 509 285.15 2 "A B B India Ltd." 484 37.99 2 "A B B India Ltd." 485 41.2 2 "A B B India Ltd." 486 40.6 2 "A B B India Ltd." 487 49.15 2 "A B B India Ltd." 488 42.32 2 "A B B India Ltd." 489 43.31 2 "A B B India Ltd." 490 52 2 "A B B India Ltd." 491 52.59 2 "A B B India Ltd." 492 53.06 2 "A B B India Ltd." 493 63.18 2 "A B B India Ltd." 494 47.52 2 "A B B India Ltd." 495 49.24 2 "A B B India Ltd." 496 55.74 2 "A B B India Ltd." 497 49.96 2 "A B B India Ltd." 498 50.4 2 "A B B India Ltd." 499 45.71 2 "A B B India Ltd." 500 39.51 2 "A B B India Ltd." 501 38.32 2 "A B B India Ltd." 502 40.97 2 "A B B India Ltd." 503 40.8 2 "A B B India Ltd." 504 44.5 2 "A B B India Ltd." 505 51.37 2 "A B B India Ltd." 506 53.11 2 "A B B India Ltd." 507 53.26 2 "A B B India Ltd." 508 49.19 2 "A B B India Ltd." 509 53.75 3 "A C C Ltd." 484 113.5 3 "A C C Ltd." 485 117.95 3 "A C C Ltd." 486 108 3 "A C C Ltd." 487 124.5 3 "A C C Ltd." 488 92.25 3 "A C C Ltd." 489 93.45 3 "A C C Ltd." 490 142.65 3 "A C C Ltd." 491 159 3 "A C C Ltd." 492 178.95 3 "A C C Ltd." 493 177.85 3 "A C C Ltd." 494 129.8 3 "A C C Ltd." 495 149.8 3 "A C C Ltd." 496 139.5 3 "A C C Ltd." 497 136.4 3 "A C C Ltd." 498 139 3 "A C C Ltd." 499 127.95 3 "A C C Ltd." 500 124.5 3 "A C C Ltd." 501 133.2 3 "A C C Ltd." 502 170.65 3 "A C C Ltd." 503 151.8 3 "A C C Ltd." 504 160 3 "A C C Ltd." 505 163.5 3 "A C C Ltd." 506 153.95 3 "A C C Ltd." 507 150.65 3 "A C C Ltd." 508 151.25 3 "A C C Ltd." 509 158.9 4 "A D C India Communications Ltd." 484 331.4 4 "A D C India Communications Ltd." 485 402.7 4 "A D C India Communications Ltd." 486 462.15 4 "A D C India Communications Ltd." 487 389.65 4 "A D C India Communications Ltd." 488 355.7 4 "A D C India Communications Ltd." 489 229.7 4 "A D C India Communications Ltd." 490 238.8 4 "A D C India Communications Ltd." 491 198.05 4 "A D C India Communications Ltd." 492 215.15 4 "A D C India Communications Ltd." 493 178.8 4 "A D C India Communications Ltd." 494 114.8 4 "A D C India Communications Ltd." 495 111.1 4 "A D C India Communications Ltd." 496 128.5 4 "A D C India Communications Ltd." 497 127.5 4 "A D C India Communications Ltd." 498 91.55 4 "A D C India Communications Ltd." 499 110.9 4 "A D C India Communications Ltd." 500 77.95 4 "A D C India Communications Ltd." 501 75.5 4 "A D C India Communications Ltd." 502 92.15 4 "A D C India Communications Ltd." 503 87 4 "A D C India Communications Ltd." 504 85.5 4 "A D C India Communications Ltd." 505 82.45 end format %tm mdate
Comment