Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Problems with reshape long


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Problems with reshape long
Date   Fri, 24 Sep 2010 03:48:42 +0000

<>

The trick is to inform -reshape- that the string values in 'scene' come from the prefix of the stub varlist, not the suffix (as it expects).
To do this, use the @ symbol as a placeholder.

See -help reshape- where it explains

       " In the example above, when we wrote "reshape wide stub", we could have written "reshape wide
        stub@" because j by default ends up as a suffix.  Had we written stu@b, then the wide variables
        would have been named stu1b and stu2b."


An example:

******************!
//generate some fake data//
clear
inp sub_num   cuestay b1famrt b2famrt b6famrt b5famrt
1  12 1 3 3 1
2 11 1 6 6 -1
3 10  0 2 2 1
4 9 0 3 3 5
5 10 1 2 2 -5
end


//reshape//
reshape long @stay @famrt, i(sub_num) j(scene) string

//if you want it in one column//
g combined = max(stay, famrt)
******************!

-Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu

>>
On Sep 23, 2010, at 10:19 PM, Kris Anderson wrote:

> The error is below.
> 
> reshape long cuestay - b6famrt, i(sub_num) j(scene) string
> (note: j = rt)
> -rt implied name too long
> r(198);
> 
> Date: Fri, 17 Sep 2010 01:48:19 +0200
> From: "Martin Weiss" <martin.weiss1@gmx.de>
> Subject: st: RE: Problems with reshape long
> 
> <>
> 
> What do the error messages say?
> 
> 
> HTH
> Martin
> 
> 
> - -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Kris Anderson
> Sent: Donnerstag, 16. September 2010 21:55
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Problems with reshape long
> 
> Hi,
> 
> I need to reshape some data in order to run a repeated measures ANOVA.
> When I try to run the syntax, I get error messages.
> 
> reshape long cuestay - b6famrt, i(sub_num) j(scene) string
> 
> The variable scene (j), hoped to be the identifier variables in long
> form, is not numeric. It is cue, a1, b1, a2, b2, etc. Each scene has
> about 5 variables that are within.
> 
> What do I need to do in order to make this work?
> 
> Thanks,
> Kris



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index