Statalist The Stata Listserver


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

st: sort strings within rows


From   Caleb Southworth <caleb@uoregon.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: sort strings within rows
Date   Tue, 5 Sep 2006 15:54:42 -0700 (PDT)

I would like to sort data within a set of variables (within a row). The
set of variables describe officer names, surname first. For example, some
of the data are

      |              tvp1                     tvp2                  tvp3 |
      |------------------------------------------------------------------|
 466. |     massagli,mark                  wood,j.        dessent,harold |
 476. |     beletz,elaine             carter,annie        curtis,barbara |
 484. |      bradshaw,joe             brown,arnold        dunaway,lowell |
 497. |    schneider,mark            mullins,bobby         sump,lawrence |


The desired outcome is

      |              tvp1                     tvp2                  tvp3 |
      |------------------------------------------------------------------|
 466. |     massagli,mark           dessent,harold               wood,j. |
 476. |     beletz,elaine             carter,annie        curtis,barbara |
 484. |      bradshaw,joe             brown,arnold        dunaway,lowell |
 497. |     mullins,bobby           schneider,mark         sump,lawrence |

such that the id number remains the same and the data are shuffled within
the tvp# variables. This will permit an assessment of change in officers
between years without looping over all the variables of a similar type
(i.e. vice presidents or presidents).

I considered using reshape, but at least in my hands that leads to a very
long kludge.

Thanks!

Caleb
caleb@uoregon.edu
University of Oregon Sociology
*
*   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