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 <nik_padazis@yahoo.com>
To   statalist@hsphsun2.harvard.edu
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 &
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/



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