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]

Re: st: RE: Reshape question


From   thomas bourveau <[email protected]>
To   [email protected]
Subject   Re: st: RE: Reshape question
Date   Sat, 30 Mar 2013 18:40:59 +0100

Dear Elan,

thanks a lot for your answer.

I applied your suggestion.

It works only partially. Indeed, I am sorry but I forgot to mention in
my initial mail that about a quarter of my identifiers are not made of
six figures (eg. "111112") but rather of five figures and a letter (eg
"11111U"). For the later case, the procedure does not apply. If I read
your procedure well, at the end I should only have three variables :
date, firmid and Vol that contains my variable of interest. However,
here, I keep the columns for all the cases with a letter in their
name.

If anyone has an idea, it would be great.

I wish you all a nice week-end
Best,
Thomas

2013/3/29 Cohen, Elan <[email protected]>:
> How about this:
>
> foreach var of varlist var2-var4 {
>         rename `var' VoI`=`var'[1]'
> }
> drop in 1
> rename var1 date
> g id = _n
> reshape long VoI, i(id) j(firmid)
> drop id
>
> HTH,
>
> - Elan
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of thomas bourveau
> Sent: Friday, March 29, 2013 14:10
> To: [email protected]
> Subject: st: Reshape question
>
> Dear Statlist readers,
>
> I now have an issue trying to reshape my dataset.
>
> Currently, a simplified version of my dataset looks as follows :
>
> var1                      var2                    var3                   var4
> Code                    111111              111112               111113
> 01/01/2000             10                        11                       22
> 01/02/2000             20                        14                       25
> ..
> ..
> 01/12/2008             23                        17                        28
>
>
> Specifically, my columns name are var1, var2, var3....
> In the first line of the dataset, except for the first column, there
> is the firms identifier.
> As you can see from my example, the next lines provide the value of my
> variable of interest for all the firms in the sample at a given point
> in time.
>
> I need to work with a dataset that would be organized as follows :
>
> Firm ID         Date                      Variable of Interest
> 111111         01/01/2000                     10
> ..
> ..
> 111111         01/12/2008                      23
> 111112         01/01/2000                      11
> ..
> ..
> 111112         01/12/2008                     17
> 111113         01/01/2000                      22
> ..
> ..
> 111113         01/12/2008                      28
>
>
> I have been through several stata tutorials online. However, I do not
> think that my case fit with the basic wide / long reshape examples
> that I've found.
>
> I would appreciate any suggestion to find a solution.
>
> Best,
> Thomas
>
> --
> Thomas Bourveau
> [email protected]
> 0637573925
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Thomas Bourveau
[email protected]
0637573925
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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