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 &
tri==-1)
by day:gen lmin=(tri==1 & tri[_n-1]==-1) | (_n==_N &
tri[_N-1]==-1)
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
li
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
http://search.yahoo.com
*
* 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/