Cindy wrote:
I need to reorder one of my variables (from lowest to
highest) without changing the order of other variables
in my dataset. Is there any simply way to do this?
Like, I have now:
var1 var2 var3 ...
3 7 9
2 10 3
7 8 5
..........
And I like to reorder var3 to get:
var1 var2 var3 ...
3 7 3
2 10 5
7 8 9
..........
Please, this is not the -reorder- command which is
already there in Stata, it is something different.
===================================================
This request confuses me. You want to -sort- one of
the variables in the dataset without affecting the sort
order of the other variables. This comes close to
eliminating the concept of an observation.
But it can be done by splitting the dataset, sorting
the parts, and merging them:
clear
input var1 var2 var3
3 7 9
2 10 3
7 8 5
end
save data1.dta, replace
gen key=_n
sort key
drop var3
save data2.dta, replace
use data1.dta
keep var3
sort var3
gen key=_n
sort key
merge key using data2.dta
But are you really sure you want to do this?
Svend
________________________________________________________
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C, Denmark
Phone, work: +45 8942 6090
Phone, home: +45 8693 7796
Fax: +45 8613 1580
E-mail: [email protected]
_________________________________________________________
*
* 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/