Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Arranging variables across rows

From   Nick Cox <njcoxstata@GMAIL.COM>
Subject   Re: st: Arranging variables across rows
Date   Wed, 27 Jun 2012 09:14:59 +0100

Follow the code given earlier with

bysort family (person) : gen col = _n
reshape wide person treated , i(family) j(col)

In practice, you would need to process the rest of your data as well,
because there is no guarantee that you recover your A* variables this
way. I want to stress (again, but for the last time in this thread)
that for almost all Stata analysis you should prefer a long structure.

There are enough tips and tricks for working rowwise to fill one
paper, but working columnwise is in effect the subject of the rest of
the documentation.

I allude to

SJ-9-1  pr0046  . . . . . . . . . . . . . . . . . . .  Speaking Stata: Rowwise
        (help rowsort, rowranks if installed) . . . . . . . . . . .  N. J. Cox
        Q1/09   SJ 9(1):137--157
        shows how to exploit functions, egen functions, and Mata
        for working rowwise; rowsort and rowranks are introduced

On Wed, Jun 27, 2012 at 8:11 AM, Nick Cox <> wrote:
> As a simple principle, we don't know about any other data if you don't
> tell us. But my question remains. I don't think this structure is one
> that is easy to work with in Stata. You could in principle easily take
> the one indicator variable just created and turn it into 19 indicator
> variables parallel to the rest of your data.
> Nick
> On Wed, Jun 27, 2012 at 4:32 AM, samuel gyetvay <> wrote:
>> the rest of my data set is organized like A1, A2, A3, ... A19, with
>> everything else overlapping. It is only B1, ... B8 that has this
>> particular structure.
>> -Sam
>> On Tue, Jun 26, 2012 at 8:26 PM, Nick Cox <> wrote:
>>> I've not thought out a -merge- solution.
>>> What's the attraction of a short structure? What can you do with it?
>>> Nick
>>> On Wed, Jun 27, 2012 at 12:12 AM, samuel gyetvay <> wrote:
>>>> Thank you for your help, Nick. I am new to stata and a lot of these
>>>> commands are unfamiliar to me (which is a good thing, given that those
>>>> I already know arent solving my problem), and I will work through your
>>>> code. Just a few questions:
>>>> The rest of my data set is organized nicely, save for this crucial
>>>> variable. I don't want to reshape unless I can return to a "short
>>>> structure." Is this possible/simple?
>>>> Also, could you possibly briefly explain what the -merge- solution
>>>> might be? No need to go into such great detail.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index