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

Re: Re: st: RE: RE: Changes of the dataset


From   "I.A.C. van de Snepscheut" <Inez.vandeSnepscheut@student.uva.nl>
To   statalist@hsphsun2.harvard.edu
Subject   Re: Re: st: RE: RE: Changes of the dataset
Date   Wed, 05 Oct 2005 14:12:46 +0200

You understood my problem very well the first time, your output was 
exactly what I wanted to have. Only I made my example a litte bit 
simpler with less variables. You must think of the same situation only 
the variables are not only price colour age id and buyer, but also a 
couple of other variables (in total something like 30 variables). I 
put all my variables between the brackets after i (just like you did) 
and than stata gave an error. The number of variabeles is too high. 
Than I tried and the maximum number of variables appeared to be 10, so 
that is a problem. Now my question was do you have a solution for this 
problem?

Inez


----- Original Message -----
From: n j cox <n.j.cox@durham.ac.uk>
Date: Wednesday, October 5, 2005 1:26 pm
Subject: Re: Re: st: RE: RE: Changes of the dataset

> Sorry, I thought that I understood what your problem was.
> Now that you have changed the problem to this vaguer
> one I don't have a clear enough picture to advise, except
> in a backwards manner: if your data don't allow a -reshape-
> solution, that may not really be a good idea.
> 
> It seems entirely possible that your original data structure
> may in fact be best overall for what you want to do. You
> just need to get fluent with -by:-, -collapse- and some other
> commands.
> 
> Nick
> n.j.cox@durham.ac.uk
> 
> I.A.C. van de Snepscheut
> 
> Hi Nick
> 
> Thanx for your quick reaction. But now I have the following 
> problem: I
> have too many variables. The maximum in this command is 10 and I have
> many more variables. Can I do it a number of times?
> 
> Nick Cox
> 
> > > This looks like a -reshape- to me.
> > >
> > > . l
> > >
> > >      +-----------------------------------+
> > >      | buyer   price   colour   age   id |
> > >      |-----------------------------------|
> > >   1. |     X      10   Yellow    12    1 |
> > >   2. |     X      10      Red    16    2 |
> > >   3. |     Y      12      Red    16    2 |
> > >   4. |     Z      13      Red    16    2 |
> > >   5. |     Z      15     Blue     4    3 |
> > >      |-----------------------------------|
> > >   6. |     Y      80    Green     1    4 |
> > >   7. |     H       6    White    20    5 |
> > >   8. |     H      10    White    20    5 |
> > >   9. |     X      14      Red    16    2 |
> > >      +-----------------------------------+
> > >
> > > . gen newid = _n
> > >
> > > . reshape wide price, i(newid id colour age) j(buyer) string
> > > (note: j = H X Y Z)
> > >
> > > Data                               long   ->   wide
> > > --------------------------------------------------------------
> > > ---------------
> > > Number of obs.                        9   ->       9
> > > Number of variables                   6   ->       8
> > > j variable (4 values)             buyer   ->   (dropped)
> > > xij variables:
> > >                                   price   ->   priceH priceX
> > > ... priceZ
> > > --------------------------------------------------------------
> > > ---------------
> > >
> > > . renpfix price
> > >
> > > . drop newid
> > >
> > > . l
> > >
> > >      +---------------------------------------+
> > >      | colour   age   id    H    X    Y    Z |
> > >      |---------------------------------------|
> > >   1. | Yellow    12    1    .   10    .    . |
> > >   2. |    Red    16    2    .   10    .    . |
> > >   3. |    Red    16    2    .    .   12    . |
> > >   4. |    Red    16    2    .    .    .   13 |
> > >   5. |   Blue     4    3    .    .    .   15 |
> > >      |---------------------------------------|
> > >   6. |  Green     1    4    .    .   80    . |
> > >   7. |  White    20    5    6    .    .    . |
> > >   8. |  White    20    5   10    .    .    . |
> > >   9. |    Red    16    2    .   14    .    . |
> > >      +---------------------------------------+
> > >
> > > See [D] reshape and the FAQ on reshape.
> > >
> > > Nick
> > > n.j.cox@durham.ac.uk
> 
> *
> *   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/
> 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index