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

Re: st: programming help


From   smerryman@kc.rr.com
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: programming help
Date   Tue, 22 Feb 2005 08:14:50 -0600

How about first transforming the row vectors into variables.  Once you have the x 
and y row vectors as variables, I believe the following should work:

clear
input y x
2 3 
4 4	
8 5
12 7
1 0
end
l

gen x_old = x
qui {
local max = .
local min = .
count
local num = r(N)
forv i = 1/`num' {
sum y if y < `max'
local max = r(max)
sum x if x < `max'
local min = r(min)
replace x = `max' if `max' > `min' & x == `min'
}
}
l y x_old x


Scott


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index