Line for the server...
It is not really clear what you want (in particular: what role does the "y"
play?)
But here is a quick and dirty solution:
************
clear*
input var1 var2
1 2
3 1
4 3
5 1
5 3
4 2
3 4
6 4
6 1
2 1
2 2
end
l, sepby(var1) noo
sort var1
preserve
tempfile new
keep var1
save `new'
restore
drop var1
sort var2
merge using `new'
order var1 var2
l
*************
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linn Renée Naper
Sent: Tuesday, November 18, 2008 10:52 AM
To: [email protected]
Subject: st: reallocating variables within observations
Hi Statalist
I have two variables x1 and x2 identified by the variable y. Then I sort the
data on x1, so that the observation with the lowest value of x1 comes first.
How can I tell stata to allocate the x2 values so that the lowest x2 is
assigned the observation with the lowest x1 etc? This is not the same as
sorting by x1 and x2, as I need to reallocate the variables within
observations.
Linn
*
* 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/
*
* 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/