Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date generation after reshaping the data

    Hello,

    This is monthly return data of various companies for year 1996. I am facing problem in generating date variable after reshaping the data from wide to long, mainly because the date format gets change as I paste the data in stata work file. Can anyone please guide how can I generate the correct date variable from this data. I am using the following command:

    reshape long ret, i(id) j(date)

    Thanks

    id company ret1/31/1996 ret2/29/1996 ret3/31/1996 ret4/30/1996 ret5/31/1996 ret6/30/1996 ret7/31/1996 ret8/31/1996 ret9/30/1996 ret10/31/1996 ret11/30/1996 ret12/31/1996
    1 Atok Big Wedge Co Inc 0 -4.1667 -18.2609 -25.5319 -14.2857 3.3333 61.2903 0.0000 0.0000 -6.0000 197.8723 192.8571
    2 Abacore Capital Holdings Inc 6.43263E-10 -5.5556 11.7647 -5.2632 0.0000 11.1111 -15.0000 -5.8824 6.2500 29.4118 -5.0000 0.0000
    3 ABS CBN Corp 7.317073168 0.0000 -3.4091 12.4781 7.3684 -7.3529 -7.9365 5.1724 -4.9180 -8.6207 -1.9231 11.7647
    4 Ayala Corp 9.09090909 1.0638 7.3684 0.0000 3.9216 -3.7037 0.0000 12.6874 11.5385 -4.5977 11.1111 -2.0889
    5 Alsons Consolidated Resources Inc 19.35483871 7.1429 -2.6667 16.4384 22.3529 4.8077 -5.5046 10.6796 1.7544 0.8621 -1.7241 -4.3860
    6 Aboitiz Equity Ventures Inc 10 -1.8182 -7.4074 2.0000 3.9216 -7.5472 -10.2041 7.8409 -6.8493 -7.3529 -11.4754 -1.8519
    7 Asiabest Group International Inc -4.76190476 3.7500 -8.4337 5.2632 20.0000 -1.1858 4.4444 -14.8936 5.0000 33.3333 28.5714 -2.7778
    8 Marcventures Holdings Inc 5 -4.6512 -7.3171 -7.8947 -11.4286 32.2581 58.5366 -7.6923 8.3333 -23.0769 60.0000 112.5000
    9 Ayala Land Inc 4.6875 4.4118 19.8167 -4.7059 11.1111 3.2967 -3.1915 10.4395 -4.4776 -12.4125 3.6364 5.2632
    10 A Soriano Corp 9.433962265 0.0000 0.0000 7.0175 18.0328 -9.8592 -12.5000 0.0000 1.7857 -1.7544 9.2593 -5.0847
    11 APC Group Inc -7.69230769 18.18181818 9.09517E-10 -7.69230769 25 21.42857143 -5.88235294 56.25 36 14.70588235 -10.81081081 -9.090909092

  • #2
    Here's one way:
    Code:
    reshape long ret, i(id) j(date)
    tostring date, replace
    replace date = "0"+date if strlen(date)==7
    gen datenew = daily(date,"MDY")
    format datenew %td
    And in future posts, please do use dataex o post dataexamples. See the FAQ on how and why: https://www.statalist.org/forums/help#stata

    Comment


    • #3
      Hi Jorrit,

      Thanks for your prompt response. The problem resolved with your provided codes. I will take care of using "dataex" next time.

      Comment

      Working...
      X