The -clsort- EGEN function (findit _gclsort) might be your friend here,
if, as Scott suggests, you have the data stored as variables. You could
go
gsort - Y
egen Xnew = clsort(X)
replace Xnew = Y if Y>Xnew
You need to check but that should be near what you want if I understand
correctly.
Hope this helps,
Philippe
<<<>>><<<>>><<<>>><<<>>><<<>>><<<>>><<<>>><<<>>>
Dr. Philippe Van Kerm
IRISS - Integrated Research Infrastructure in
the Socio-Economic Sciences
CEPS/INSTEAD
BP48, L-4501 Differdange, Luxembourg
>> http://www.ceps.lu/iriss <<
>> http://econpapers.hhs.se/RAS/pva19.htm <<
<<<>>><<<>>><<<>>><<<>>><<<>>><<<>>><<<>>><<<>>>
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept
**********************************************************************
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/