Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: RE: Another reshape wide question


From   "Amber Katz" <academicgirl@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: RE: Another reshape wide question
Date   Tue, 18 Apr 2006 13:22:29 -0400

Hi Nick,

I did read these pages before I got to this list, and they were very
helpful.  Let me be more specific about my problem with an example:

Suppose that, for each individual and for each round, I have the
following variables:
OpinionA OpinionB OpinionC.  Now suppose I have many variables that
are individual-specific and do not differ among products: Gender,
Married, Nationality, etc.

What I'd like is to have the variable in form:
ID Opinion1A-Opinion3A Opinion1B-Opinion3B Opinion1C-Opinion3C Gender
Married Nationality.

So I need to do a reshape long on the opinion variables by product (A,
B, and C).  I'd like to do this without generating GenderA-GenderC,
MarriedA-MarriedC and NationalityA-NationalityC variables as I have
many of these.

My data was originally in long form, so I did a renvars and reshape
wide (on the subvariable "round"), and the data is now of form
ID Opinion1A-Opinion3A [Opinion*B and Opinion*C blank] Gender1-3
Married1-3 Nationality1-3
ID [Opinion*A and Opinion*C blank] Opinion1B-Opinion3B  Gender1-3
Married1-3 Nationality1-3
ID [Opinion*A and Opinion*B blank] Opinion1C-Opinion3C  Gender1-3
Married1-3 Nationality1-3

I'd like to convert into the long form (by product) specified above.

Thanks very much,
Amber

On 4/18/06, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> Also, check out:
>
> FAQ     . . . . . . . . . . . . . . . . . . . . . . . Replacing missing values
>        2/03    How can I replace missing values with previous or
>                following nonmissing values?
>                http://www.stata.com/support/faqs/data/missing.html
>
> Nick
> n.j.cox@durham.ac.uk
>
> Nick Cox
>
> > You've answered your own question. The answer is No,
> > in your circumstances.
> >
> > Stata is not being awkward: it just doesn't see that
> > your proposed -reshape- make sense.
>
> [snip]
>
> > Amber Katz
> >
> > > Thanks for all the responses to my previous question.  One
> > other one:
> > > Will Stata let me "reshape" some variables wide and not others (the
> > > ones that are time invariant and hence missing in
> > observations 2 and 3
> > > for each individiual)?  When I try to do this, it tells me
> > that those
> > > variables are not constant for each person.
>
> [snip]
>
>
> *
> *   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