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

st: RE: RE: reallocating variables within observations

From   "Nick Cox" <>
To   <>
Subject   st: RE: RE: reallocating variables within observations
Date   Tue, 18 Nov 2008 11:21:57 -0000

Linn's statement is an understatement. This kind of allocation is strong stuff. See -cquantile- and -fixsort- on SSC for what may be  answers to your question, and always keep copies of the data as they are now. 


Martin Weiss

It is not really clear what you want (in particular: what role does the "y"

But here is a quick and dirty solution:

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
l, sepby(var1) noo
sort var1
tempfile new
keep var1
save `new'
drop var1
sort var2
merge using `new'
order var1 var2

Linn Renée Naper

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

*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index