Now, I need to select and output observations that have a continuous sequence of at least three 1's. For example, where X=20, Y=100, observations 5-7 should be selected; X=21, Y=101, observations 1-3 and 5-7 should be selected; X=22, Y=102, observation 1-7 should be selected. Can anybody offer any suggestions? Thanks in advance.
Using PROC SUMMARYwith a CLASS / BY (sorted) list, and then merge back (a DATA step MERGE with a BY and using IN=I_summary_candidate_var on the summarized file) the candidate summary-level observations back into your detail data (where non-zero condition) to select candidate detail observations.
create table final as
select a.x, a.y, a.cnt,b.count
from dy a
,( select x, y, cnt, count , count(count) as xx
group by x,y,cnt,count
having count(count) >= 3