Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: reshaping data


From   Seb Buechte <[email protected]>
To   [email protected]
Subject   Re: st: reshaping data
Date   Wed, 30 Mar 2005 14:39:39 +0200

Dear Sascha,

your proposed solution is truly a workaround which may turn out to be
limited or compute/time-consuming. You should really consider reading
- help reshape -. Your data comes in "long" shape. This is multiple
records each record numbered (in you data done so by "time") relative
to the subject of interest (in you data identified by "id"). Now you
want to have the data in "wide" shape. Just as Jean-Benoit pointed out
earlier.

.ren var var_t
.reshape var_t, i(id) j(time)

"Wide" shape means a single record for each id, this record holds all
the information from the multiple records before. The data is no
longer arranged "vertically" but now it is "horizontally".

I hope this helps,

Sebastian



On Wed, 30 Mar 2005 14:30:20 +0200, Sascha Robert
<[email protected]> wrote:
> Hi
> 
> . separate var, by(time) gen(var_t)
> . collapse var_t1-var_tn, by(id)
> 
> does the trick.
> 
> I found the solution in STATA help, but not in my darn expensive book
> "Statistics with STATA" by L.C. Hamilton.
> 
> Thanks for your help.
> 
> Best regards,
> Sascha
> 
> Sascha Robert wrote:
> > Hello
> >
> > I would like to reshape some data. Now it looks something like this:
> >
> > id    time    var
> > 1     1       x
> > 2     1       y
> > 1     2       z
> > 2     2       w
> >
> > I would like to change it to
> >
> > id    var_t1    var_t2
> > 1     x         z
> > 2     y         w
> >
> > Any hints?
> >
> > Kind regards,
> > Sascha
> >
> 
> --
> ***** sascha robert | mailto: [email protected] *****
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


-- 
- Seb F Buechte
-
- Stay tuned!
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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