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

Re: st: help to find maximum drop in a variable

From   n p <[email protected]>
To   [email protected]
Subject   Re: st: help to find maximum drop in a variable
Date   Tue, 2 Mar 2004 06:58:50 -0800 (PST)

This was indeed an interresting problem. While I was
trying to find a solution responses from Nick and
David appeared on the list. Anyway, this is my
solution ( I think it's similar to David's):

sort day hour
by day:gen change=press[_n+1]-press
by day:gen tri=-1*(change<0)+(change>0)
by day:gen lmax=(tri==-1 & tri[_n-1]==1) | (_n==1 &
by day:gen lmin=(tri==1 & tri[_n-1]==-1) | (_n==_N &
keep if lmax==1 | lmin==1
by day:gen drop=press-press[_n-1]
by day:gen prev_press=press[_n-1]
by day:gen prev_hour=hour[_n-1]
sort day drop
by day:keep if _n==1
keep pressure hour prev* drop

I think that it's working properly but needs
modifications for the case of two or more equal
adjacent pressure measurements.

Nikos Pantazis

Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
*   For searches and help try:

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