On Tue, Apr 15, 2008 at 3:27 PM, Jon Schwabish <[email protected]> wrote:
> Dear List,
>
> I'm hoping someone can help me with this b/c I'm
> totally stumped. I have a wide data set and am trying
> to identify observations that have a series of
> consecutive zeros following any positive number.
Something like this?
clear
input str4 id y1 y2 y3 y4 y5
ObsA 1 1 1 1 0
ObsB 1 1 1 0 0
ObsC 1 1 0 0 1
ObsD 1 0 1 1 1
ObsE 0 0 0 0 1
ObsF 1 5 7 2 0
ObsG 1 0 1 0 1
end
forv i = 1/4 {
gen diff`i' =1 if y`i' == 0 & y`=`i' +1' !=0
}
egen tag = anymatch(diff*), values(1)
drop diff*
l
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/