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]

st: Reorder variables in dataset, based on its values


From   Pedro Nakashima <nakashimapedrolist@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Reorder variables in dataset, based on its values
Date   Mon, 17 Dec 2012 07:45:14 -0200

Dear statalisters

I'm looking for a way to reorder variables in dataset, based on the
values of a specific observation. For example:

**IF MY DATASET IS:
clear*
input str5 othervariable v1 v2 v3 v4 v5
"obs1" 1 3 2 5 4
"obs2" 2 2 3 3 3
end

**I WANT THE DATASET ORDERED IN THIS FASHION
**(descending reordering, by observation 1)
order v4 v5 v2 v3 v1, after(othervariable)

Anyone out there know of any way to do this?

And if I wanted, instead, reorder by observation 2, or in ascending order?

Many thanks
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index