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: Problems with the reshape command


From   Syed Basher <syed.basher@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Problems with the reshape command
Date   Wed, 19 Jan 2011 08:49:00 -0800 (PST)

Dear Statalist,

I am using Stata 11.1.  I have the following hypothetical data:

     +--------------------------+
      | port       item     price      |
      |--------------------------|
  1. |        3    4029   27.62  |
  2. |        3    4029   15.47  |
  3. |        1    1006   37.55  |
  4. |        3    2045   15.18  |
  5. |        1    2045   16.21  |
      |------------------------|
  6. |        1    4061   92.79 |
  7. |        2    8041   12.55 |
  8. |        2    2011   89.68 |
  9. |        3    7031   68.01 |
10. |        2    2011   13.13 |
      |-----------------------|

I would like to reshape the data to wide format using:
. reshape wide price, i(port) j(item)

This is of course problematic in Stata since "item" is not unique within 
"port".  Eventually I would like to obtain the following cross-tab (in wide 
format):

port |       1006     2011     2045     4029     4061     7031     8041   
-------------------------------------------------------------------
1     |        37.55                16.21                 92.79
2     |                   
89.68                                                        12.55
2     |                   13.33
3     |                                15.18     27.62                  68.01
3     |                                              15.47

I have been consulting Stata's FAQs on this issue 
(http://www.stata.com/support/faqs/data/reshape3.html) without much success.  I 
hope you can help me.

Sincerely,

Syed Basher
Qatar National Food Security Program



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