Bookmark and Share

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


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

st: Reorder variables in dataset, based on its values


From   Pedro Nakashima <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index