```Date: Mon, 6 Feb 2006 23:16:19 -0500 Reply-To: Arthur Tabachneck Sender: "SAS(r) Discussion" From: Arthur Tabachneck Subject: Re: How to Identify Consecutive Visits Comments: To: Lixun Qin Jack, I'm sure there are numerous possible solutions. One way might be: data whatever (drop i counter); array day(10)day1-day10; input Patient_id day1 day2 day3 day4 day5 day6 day7 day8 day9 day10; counter=0; maximum_consecutive_visits=0; do i=1 to 10; if day(i) eq 1 then counter+1; if day(i) ne 1 or i eq 10 then do; if counter gt maximum_consecutive_visits then maximum_consecutive_visits=counter; counter = 0; end; end; cards; 1001 1 1 0 1 1 1 0 0 0 0 1002 1 1 1 1 1 0 0 1 1 1 1003 1 1 1 1 1 1 1 1 1 1 1004 1 1 0 0 0 0 0 0 0 0 ; run; Art ---------- On Mon, 6 Feb 2006 22:44:17 -0500, jack quin wrote: >Hi, SAS-L, > >I have a dataset which list each patience visits during 10 days. I want to >known how many patience make at least 3 consecutive visits, at least 5 >consecutive visits, at least 10 consecutive visits. Here is the dataset: > >Patience id day1 day2 day3 day4 day5 day6 day7 day8 >day9 day10 >1001 1 1 0 1 1 1 >0 0 0 0 ----- this >patience has at least 3 consecutive visits >1002 1 1 1 1 1 0 >0 1 1 1 ------ this >patience has at least 5 consecutive visits >1003 1 1 1 1 1 1 >1 1 1 1 ------ this >patience has at least 10 consecutive visits >1004 1 1 0 0 0 0 >0 0 0 0 -------- no 3 >consecutive visits >..... > > >I want to create a flag: 1: at least 10 consecutive visits; 2: at least 5 >consecutive visits; 3 at least 3 consecutive visits; 4 less than 3 >consecutive visits/no visits. > >Do you know how I can create it? > > >Thanks in advance. ```

Back to: Top of message | Previous page | Main SAS-L page