Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Combine the observations of many variables under one variable


From   Nadine R <[email protected]>
To   [email protected]
Subject   st: Combine the observations of many variables under one variable
Date   Wed, 22 Jun 2011 15:04:21 +0200

Hello statalisters!

I am a very new stata user (for only three weeks now) but with the
help of the archive I managed many things to work. What I could not
find in the archive is the answer to the following problem. I am
working with stata version 11.0. The dataset looks like this:

Date             Company1              Company2             Company3 …
     Company700
01.01.2002         1                             2
       1                          3
02.01.2002         3                             1
       2                          1
03.01.2002         2                             3
       1                          4
…
31.05.2011         1                             2
       3                          4

The numbers represent some share prices or returns. I need to
transform this dataset into a table that looks like this:

Company            Date                      Return

1                       01.01.2002                 1
                         02.01.2002                 3
                         03.01.2002                 2
                         …
                         31.05.2011                 1
2                       01.01.2002                 2
                         02.01.2002                 1
                         03.01.2002                 3
                         …
                         31.05.2011                 2
3                       01.01.2002                 1
                         02.01.2002                 2
                         03.01.2002                 1
                         …
                         31.05.2011                 3
…
700                   01.01.2002                  3
                        02.01.2002                  1
                        03.01.2002                  4
                        …
                        31.05.2011                  4



I know that it has to work somehow with a for-loop, but I couldn’t
manage to tell stata that it should jump into the first empty row and
copy the values from company2 and so on. And I know that it will
become a huge dataset: 9 years*250 days*700 companies. Can Stata
handle sets like this?



Thank you a lot in advance for your help.

Nadine

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index