Announcement

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

  • Reshape Long

    I want to format my data from this pattern:
    Company Name Jul-03 Aug-03 Sep-03 Oct-03 Nov-03 Dec-03 Jan-04 Feb-04 Mar-04 Apr-04 May-04 Jun-04
    3M India Ltd. 0.0042 0.1025 0.1178 0.0034 0.206 0.0389 -0.2038 -0.0242 0.0272 0.1828 -0.1733 0.0665
    63 Moons Technologies Ltd. #DIV/0! -0.0303 -0.1369 0.403 0.8332 0.6212 0.4796 -0.0269 -0.0774 0.0493 -0.3822 0.0319
    A B B India Ltd. 0.0283 0.2542 0.0032 0.0996 0.0103 0.2712 -0.0077 0.045 0.1392 -0.0154 -0.1892 0.0579
    A C C Ltd. 0.1626 0.094 -0.0438 0.0547 0.06 0.0815 0.0399 0.0174 -0.0202 0.0998 -0.1534 0.0211
    A G C Networks Ltd. 0.0619 0.1691 -0.027 -0.056 0.491 0.2019 -0.0779 -0.0641 -0.0441 0.0464 -0.0137 0.0136
    Aarti Industries Ltd. 0.3472 -0.049 0.4614 0.0276 -0.0738 0.5209 -0.1625 0.0525 -0.0613 -0.0928 -0.0176 -0.0086
    Aban Offshore Ltd. 0.0438 -0.0856 0.287 0.0165 0.3008 0.0211 -0.19 0.0589 0.2318 0.0065 -0.0428 0.2923
    Abbott India Ltd. 0.0386 0.0591 0.0681 0.0629 0.1413 0.1509 -0.1587 0.1458 0.1108 -0.0253 -0.1544 0.0387
    Accelya Solutions India Ltd. 0.0362 0.0583 -0.0612 -0.0756 0.5134 0.068 -0.2696 -0.1135 -0.1105 0.0939 0.0512 -0.0303
    Adani Enterprises Ltd. -0.0732 0.0592 0.0166 -0.0244 0.1148 0.8174 -0.0773 0.0508 0.0643 0.0664 0.1161 0.047
    Aditya Birla Nuvo Ltd. [Merged] 0.1443 0.2278 -0.0072 0.082 0.1992 0.157 -0.222 -0.0883 -0.0133 0.1324 -0.0629 0.0159
    Ador Welding Ltd. -0.0013 0.0458 0.1237 -0.1124 0.0116 0.2056 -0.2352 -0.1094 -0.0902 0.0598 0.1484 0.0955
    Aftek Ltd. 0.1374 -0.003 -0.0114 -0.1206 0.0422 0.5829 -0.1061 -0.2273 -0.0575 0.4115 -0.1569 0.0216
    to the following pattern:
    stock month rt
    3M India Ltd. Jul-03 0.004189
    3M India Ltd. Aug-03 0.102503
    3M India Ltd. Sep-03 0.117838
    3M India Ltd. Oct-03 0.003385
    3M India Ltd. Nov-03 0.206024
    3M India Ltd. Dec-03 0.038861
    3M India Ltd. Jan-04 -0.20377
    3M India Ltd. Feb-04 -0.02415
    3M India Ltd. Mar-04 0.027228
    3M India Ltd. Apr-04 0.182771
    3M India Ltd. May-04 -0.17327
    3M India Ltd. Jun-04 0.066535
    63 Moons Technologies Ltd. Jul-03 #DIV/0!
    63 Moons Technologies Ltd. Aug-03 -0.03027
    63 Moons Technologies Ltd. Sep-03 -0.13694
    63 Moons Technologies Ltd. Oct-03 0.402952
    63 Moons Technologies Ltd. Nov-03 0.833246
    63 Moons Technologies Ltd. Dec-03 0.621234
    63 Moons Technologies Ltd. Jan-04 0.479646
    63 Moons Technologies Ltd. Feb-04 -0.02691
    63 Moons Technologies Ltd. Mar-04 -0.07744
    63 Moons Technologies Ltd. Apr-04 0.0493
    63 Moons Technologies Ltd. May-04 -0.38222
    63 Moons Technologies Ltd. Jun-04 0.03186
    A B B India Ltd. Jul-03 0.028339
    A B B India Ltd. Aug-03 0.254219
    A B B India Ltd. Sep-03 0.003154
    A B B India Ltd. Oct-03 0.09956
    A B B India Ltd. Nov-03 0.010294
    A B B India Ltd. Dec-03 0.271226
    A B B India Ltd. Jan-04 -0.00772
    A B B India Ltd. Feb-04 0.045023
    A B B India Ltd. Mar-04 0.139197
    A B B India Ltd. Apr-04 -0.01539
    A B B India Ltd. May-04 -0.18924
    A B B India Ltd. Jun-04 0.057921
    A C C Ltd. Jul-03 0.162575
    A C C Ltd. Aug-03 0.093999
    A C C Ltd. Sep-03 -0.04379
    A C C Ltd. Oct-03 0.054653
    A C C Ltd. Nov-03 0.059991
    A C C Ltd. Dec-03 0.08148
    A C C Ltd. Jan-04 0.03991
    A C C Ltd. Feb-04 0.017427
    A C C Ltd. Mar-04 -0.02021
    A C C Ltd. Apr-04 0.099784
    A C C Ltd. May-04 -0.15342
    A C C Ltd. Jun-04 0.021097
    A G C Networks Ltd. Jul-03 0.061866
    A G C Networks Ltd. Aug-03 0.169081
    A G C Networks Ltd. Sep-03 -0.02703
    A G C Networks Ltd. Oct-03 -0.05596
    A G C Networks Ltd. Nov-03 0.491029
    A G C Networks Ltd. Dec-03 0.201868
    A G C Networks Ltd. Jan-04 -0.07785
    A G C Networks Ltd. Feb-04 -0.0641
    A G C Networks Ltd. Mar-04 -0.04408
    A G C Networks Ltd. Apr-04 0.046408
    A G C Networks Ltd. May-04 -0.01373
    A G C Networks Ltd. Jun-04 0.013641
    Aarti Industries Ltd. Jul-03 0.347202
    Aarti Industries Ltd. Aug-03 -0.04899
    Aarti Industries Ltd. Sep-03 0.461366
    Aarti Industries Ltd. Oct-03 0.027586
    Aarti Industries Ltd. Nov-03 -0.07383
    Aarti Industries Ltd. Dec-03 0.520934
    Aarti Industries Ltd. Jan-04 -0.16252
    Aarti Industries Ltd. Feb-04 0.052465
    Aarti Industries Ltd. Mar-04 -0.06126
    Aarti Industries Ltd. Apr-04 -0.09277
    Aarti Industries Ltd. May-04 -0.01763
    Aarti Industries Ltd. Jun-04 -0.00861
    Aban Offshore Ltd. Jul-03 0.043824
    Aban Offshore Ltd. Aug-03 -0.08559
    Aban Offshore Ltd. Sep-03 0.287006
    Aban Offshore Ltd. Oct-03 0.016529
    Aban Offshore Ltd. Nov-03 0.300813
    Aban Offshore Ltd. Dec-03 0.021146
    Aban Offshore Ltd. Jan-04 -0.19004
    Aban Offshore Ltd. Feb-04 0.058942
    Aban Offshore Ltd. Mar-04 0.231803
    Aban Offshore Ltd. Apr-04 0.006469
    Aban Offshore Ltd. May-04 -0.04279
    Aban Offshore Ltd. Jun-04 0.292343
    Abbott India Ltd. Jul-03 0.038646
    Abbott India Ltd. Aug-03 0.059104
    Abbott India Ltd. Sep-03 0.068086
    Abbott India Ltd. Oct-03 0.062873
    Abbott India Ltd. Nov-03 0.141312
    Abbott India Ltd. Dec-03 0.15093
    Abbott India Ltd. Jan-04 -0.15866
    Abbott India Ltd. Feb-04 0.145831
    Abbott India Ltd. Mar-04 0.110835
    Abbott India Ltd. Apr-04 -0.02531
    Abbott India Ltd. May-04 -0.1544
    Abbott India Ltd. Jun-04 0.038739
    Accelya Solutions India Ltd. Jul-03 0.036242
    Accelya Solutions India Ltd. Aug-03 0.05829
    Accelya Solutions India Ltd. Sep-03 -0.0612
    Accelya Solutions India Ltd. Oct-03 -0.07562
    Accelya Solutions India Ltd. Nov-03 0.513399
    Accelya Solutions India Ltd. Dec-03 0.068034
    Accelya Solutions India Ltd. Jan-04 -0.26963
    Accelya Solutions India Ltd. Feb-04 -0.1135
    Accelya Solutions India Ltd. Mar-04 -0.11051
    Accelya Solutions India Ltd. Apr-04 0.093939
    Accelya Solutions India Ltd. May-04 0.051247
    Accelya Solutions India Ltd. Jun-04 -0.0303
    Adani Enterprises Ltd. Jul-03 -0.07317
    Adani Enterprises Ltd. Aug-03 0.059211
    Adani Enterprises Ltd. Sep-03 0.016563
    Adani Enterprises Ltd. Oct-03 -0.02444
    Adani Enterprises Ltd. Nov-03 0.114823
    Adani Enterprises Ltd. Dec-03 0.817416
    Adani Enterprises Ltd. Jan-04 -0.07728
    Adani Enterprises Ltd. Feb-04 0.05081
    Adani Enterprises Ltd. Mar-04 0.064293
    Adani Enterprises Ltd. Apr-04 0.0664
    Adani Enterprises Ltd. May-04 0.116105
    Adani Enterprises Ltd. Jun-04 0.04698
    Aditya Birla Nuvo Ltd. [Merged] Jul-03 0.144267
    Aditya Birla Nuvo Ltd. [Merged] Aug-03 0.227754
    Aditya Birla Nuvo Ltd. [Merged] Sep-03 -0.0072
    Aditya Birla Nuvo Ltd. [Merged] Oct-03 0.081977
    Aditya Birla Nuvo Ltd. [Merged] Nov-03 0.199171
    Aditya Birla Nuvo Ltd. [Merged] Dec-03 0.157045
    Aditya Birla Nuvo Ltd. [Merged] Jan-04 -0.22203
    Aditya Birla Nuvo Ltd. [Merged] Feb-04 -0.08832
    Aditya Birla Nuvo Ltd. [Merged] Mar-04 -0.01334
    Aditya Birla Nuvo Ltd. [Merged] Apr-04 0.132351
    Aditya Birla Nuvo Ltd. [Merged] May-04 -0.06287
    Aditya Birla Nuvo Ltd. [Merged] Jun-04 0.015945
    Ador Welding Ltd. Jul-03 -0.00135
    Ador Welding Ltd. Aug-03 0.045822
    Ador Welding Ltd. Sep-03 0.123711
    Ador Welding Ltd. Oct-03 -0.11239
    Ador Welding Ltd. Nov-03 0.011628
    Ador Welding Ltd. Dec-03 0.205619
    Ador Welding Ltd. Jan-04 -0.23517
    Ador Welding Ltd. Feb-04 -0.10942
    Ador Welding Ltd. Mar-04 -0.0902
    Ador Welding Ltd. Apr-04 0.059829
    Ador Welding Ltd. May-04 0.148387
    Ador Welding Ltd. Jun-04 0.095506
    Aftek Ltd. Jul-03 0.137437
    Aftek Ltd. Aug-03 -0.00297
    Aftek Ltd. Sep-03 -0.0114
    Aftek Ltd. Oct-03 -0.12058
    Aftek Ltd. Nov-03 0.042189
    Aftek Ltd. Dec-03 0.582877
    Aftek Ltd. Jan-04 -0.1061
    Aftek Ltd. Feb-04 -0.22733
    Aftek Ltd. Mar-04 -0.05754
    Aftek Ltd. Apr-04 0.411468
    Aftek Ltd. May-04 -0.15686
    Aftek Ltd. Jun-04 0.021637
    Please suggest an appropriate STATA reshape code to my data.

  • #2
    Please tell us your variable names, as none of


    Code:
     
    Company Name Jul-03 Aug-03
    and so on is a legal variable name. See also FAQ Advice #12 on using dataex to clarify this kind of detail.

    Comment


    • #3
      The Variable is just one, i.e., monthly stock return.

      Comment


      • #4
        You've shown us something that looks more like a view of a spreadsheet. We need to know what your variables are called in Stata in the dataset you have in Stata. If you've not read the data into Stata yet, the question is premature.

        Comment


        • #5
          i did not fed the data to Stata yet. I have pasted the data from spreadsheet. It has just one variable, i.e. rt = (monthly stock return) which is shown for each month in different columns. Is there any change needed to be brought in the var labels to make it stata readable?

          Comment


          • #6
            Code:
            db import excel
            to read the data into Stata.

            Comment


            • #7
              That is for importing data and not reshape

              Comment


              • #8
                #5 said

                I did not feed the data to Stata yet.
                So, I advised reading the data into Stata first. You can't reshape the data before reading them in.

                If you have read the data in, then please go back to #2 and tell us the variable names.

                Comment


                • #9
                  Thanks indeed Nick for your suggestions. I understood how it is to be done and got it done. For variable shown as months, prefix of verbal name was to be added. For instance, rt72009 instead of simply 72009.

                  Comment


                  • #10
                    I want to order months beginning 72009 to 62010. When i reshape, by default the order of months is given as 12020 to 122009. Please suggest the code

                    Comment


                    • #11
                      I hope someone else can help you here. It seems that you don't understand what I am asking, and I am out of ways to explain it.

                      Comment

                      Working...
                      X