Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: programming help


From   "philippe van kerm" <[email protected]>
To   <[email protected]>
Subject   st: Re: programming help
Date   Tue, 22 Feb 2005 17:06:00 +0100

>
>Re: st: programming help
>From 	  Seb Buechte <[email protected]>
>To 	  [email protected]
>Subject 	  Re: st: programming help
>Date 	  Tue, 22 Feb 2005 16:12:11 +0100
>
>Philippe, a godd suggestion, but it does not work if you need to
>preserve the order of the values in X and Y. I guess working with
>matrices is the solution here,

True, but that is not too much of a problem:

gen rememberorder = _n
 gsort - Y
 egen Xnew = clsort(X)
 replace Xnew = Y if Y>Xnew
sort rememberorder

A more elaborate option could save the sort order and restore it
afterwards (using local macname :  sortedby)

Philippe


**********************************************************************
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/



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