Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: RE: Reshape question


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: Reshape question
Date   Sat, 30 Mar 2013 18:38:42 +0000

Try the extra option -string-, for which see the help for -reshape-.

Nick

On 30 Mar 2013, at 17:40, thomas bourveau <thomas.bourveau@gmail.com> wrote:

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 <cohened@upmc.edu>:
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: owner-statalist@hsphsun2.harvard.edu [mailto:owner- statalist@hsphsun2.harvard.edu] On Behalf Of thomas bourveau
Sent: Friday, March 29, 2013 14:10
To: statalist@hsphsun2.harvard.edu
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.




*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index