Statalist


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

RE: st: RE: reshape problem


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: reshape problem
Date   Tue, 9 Dec 2008 20:17:50 -0000

Although you are asked _not_ to send attachments -- as I should perhaps
have reminded you in my previous post -- this one got through to me and 
I found that your data -reshape- fine: 

. ds
x1963  x1967  x1971  x1975  x1979  x1983  x1987  x1992  x1996  x2001
x2005
x1964  x1968  x1972  x1976  x1980  x1984  x1989  x1993  x1997  x2002
x2006
x1965  x1969  x1973  x1977  x1981  x1985  x1990  x1994  x1999  x2003
regio
x1966  x1970  x1974  x1978  x1982  x1986  x1991  x1995  x2000  x2004

. isid regio

. reshape long x, i(regio) j(year)
(note: j = 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
1975 1976 1977 1978 1979 1
> 980 1981 1982 1983 1984 1985 1986 1987 1989 1990 1991 1992 1993 1994
1995 1996 1997 1999 2000
>  2001 2002 2003 2004 2005 2006)

Data                               wide   ->   long
------------------------------------------------------------------------
-----
Number of obs.                       21   ->     882
Number of variables                  43   ->       3
j variable (42 values)                    ->   year
xij variables:
                  x1963 x1964 ... x2006   ->   x
------------------------------------------------------------------------
-----

. su

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       regio |       882          11    6.058736          1         21
        year |       882    1984.095    12.81874       1963       2006
           x |       882    31.23255    9.333917      9.844     50.513

The problem if there is one would seem to lie in your Stata, but I can't
say what it is. 

Nick 
[email protected] 

Emanuele Millemaci

As the file *.dta containing the dataset is small(few KB), I try to
send it attached to this message. Alternatively, such a file can be
downloaded  at this link:

http://www.2shared.com/file/4425484/c1951cbd/produc.html
(perhaps, need to wait few seconds before displaying the working link
at the bottom of the page)

The command I use is
reshape long x, i(regio) j(year)

2008/12/9 Nick Cox <[email protected]>:

> Despite various attempts your problem looks just as puzzling as when
> first posted.
>
> If there is some way for you to post your data file in an accessible
> place, interested people will be able to look themselves.
>
> Alternatively, I suggest you get in touch with StataCorp tech-support.
I
> guess they will want a copy of the file too.
>
> Nick
> [email protected]
>
> Emanuele Millemaci
>
>>>>> I had a dataset on excel with regions on the rows and years on the
> columns.
>>>>> I moved this data to Stata 10.1 MP(updated to the latest packages)
> and
>>>>> was trying to reshaping from wide to long as I would like to have
> all
>>>>> years' data of the same variable on the same column.
>>>>>
>>>>> Below, I report an example of what I have:
>>>>>
>>>>> regio prod1995 prod1996 .....prod2006
>>>>>
>>>>> 1         ....             ...            ...
>>>>> 2          ...             ...            ...
>>>>> 3         ...              ...            ...
>>>>> 4         ...             ...            ...
>>>>>
>>>>> I would like to get:
>>>>>
>>>>> regio years    prod
>>>>> 1      1995    ...
>>>>> 1      1996    ...
>>>>> ..
>>>>> 2      1995    ...
>>>>> ..
>>>>> 3      1995    ...
>>>>> ..
>>>>> 4      1995    ...
>>>>> ..
>>>>>
>>>>> The command I use is:
>>>>>
>>>>> reshape long prod, i(regio) j(year)
>>>>>
>>>>> It would appear a very easy task. Instead, the result I get is
> always
>>>>> different (every time I launch the command) and never correct.
>>>>> Stata drops many observations and many others become missing for
> some
>>>>> variable (whereas my dataset has no missing value). I have also
>>>>> checked that Stata considers data as numeric.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index