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: reshape problem [was: Re: st: From: Qunzi Zhang <[email protected]>]


From   "MacQuarrie, Kerry" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: reshape problem [was: Re: st: From: Qunzi Zhang <[email protected]>]
Date   Thu, 1 Nov 2012 15:26:27 +0000

Reshape is the command you want; explore the help file for that syntax to be sure and to make sure your i's and j's are clearly identified as you want them to be.

It appears that your data are currently in "long" form and you want to reshape "wide"; and that your i's are date and your j's are permno (firm).  When you reshape wide, you're repeating variables (e.g. permno, prc) will be appended with _1, _2, etc. I always find it helpful to sort the data before running a reshape command.

Regards,
Kerry

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Qunzi Zhang
Sent: Thursday, November 01, 2012 11:17 AM
To: [email protected]
Subject: Re: reshape problem [was: Re: st: From: Qunzi Zhang <[email protected]>]

Hi Nick,
I am not doing analysis in Stata neither for panel analysis. But using stata, I want to have the format which I shown as before.

Thanks


On Thu, Nov 1, 2012 at 4:13 PM, Nick Cox <[email protected]> wrote:
> Your data doesn't obviously have a panel identifier, unless it is -permno-.
>
> The command to reshape your data is called -reshape-.
>
> Your data already seem to have the best structure for most panel 
> analyses. It's not clear that you will be better off reshaping.
>
> Nick
>
> On Thu, Nov 1, 2012 at 3:06 PM,  <[email protected]> wrote:
>
>> May I ask you a question about construction the data set?
>>
>> Currently I have the following panel data format
>> permno    date    prc
>> 27174    19700102    56.375
>> 20386    19700102    34
>> 12052    19700102    28.75
>> 27174    19700101    56.375
>> 20386    19700101    34
>> 12052    19700101    28.75
>>
>>
>>
>> in Stata, how can I reshape the data and get the format as below: a 
>> big matrix the row is the date, column is the firm identity permno 
>> and input is the stock price?
>>
>> date          firm 1 firm2 firm3 .....(permno as identifer index for firm)
>> 19700101   56.37 5.37 6.35
>> 19700102  .7  .37 .35
>>
>>
>> I think merge could be the correct command but using it might create 
>> a lot of dta wrt each firm.... Can you please suggest me an efficient 
>> way to do this?
> *
> *   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/



*
*   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